{"thread":{"id":"34138","subject":"[PATCH v2 0/5] Write a good 'git stash store' for autostash","startedAt":"2013-06-14T10:31:59Z","lastAt":"2013-06-14T15:16:36Z","messageCount":13,"participants":["Ramkumar Ramachandra","Phil Hord","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"220796","messageId":"1371205924-8982-1-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":null,"subject":"[PATCH v2 0/5] Write a good 'git stash store' for autostash","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:31:59Z","receivedAt":"2013-06-14T10:31:59Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nSo, I've taken Junio's suggestion and designed a proper command-line\ninterface for 'git stash store' in this iteration:\n\n  git stash store [-m <message>] [-e <error>] <commit>\n\nThe error string will be passed through eval_gettext before it is\nprinted.  Otherwise, the idea is the same: to clean up the logic\nsurrounding autostash.\n\nThanks.\n\nRamkumar Ramachandra (5):\n  stash doc: add a warning about using create\n  stash doc: document short form -p in synopsis\n  stash: simplify option parser for create\n  stash: introduce 'git stash store'\n  rebase: use 'git stash store' to simplify logic\n\n Documentation/git-stash.txt | 12 ++++++++--\n git-rebase.sh               |  6 +----\n git-stash.sh                | 53 ++++++++++++++++++++++++++++++++++++---------\n t/t3903-stash.sh            | 19 ++++++++++++++++\n 4 files changed, 73 insertions(+), 17 deletions(-)\n\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220797","messageId":"1371205924-8982-2-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 1/5] stash doc: add a warning about using create","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:32:00Z","receivedAt":"2013-06-14T10:32:00Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Add a note saying that the user probably wants \"save\" in the create\ndescription.  While at it, document that it can optionally take a\nmessage in the synopsis.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-stash.txt | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 711ffe1..83bb3db 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -16,7 +16,7 @@ SYNOPSIS\n 'git stash' [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]\n \t     [-u|--include-untracked] [-a|--all] [<message>]]\n 'git stash' clear\n-'git stash' create\n+'git stash' create [<message>]\n \n DESCRIPTION\n -----------\n@@ -151,6 +151,7 @@ create::\n \n \tCreate a stash (which is a regular commit object) and return its\n \tobject name, without storing it anywhere in the ref namespace.\n+\tThis is probably not what you want to use; see \"save\" above.\n \n \n DISCUSSION\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220798","messageId":"1371205924-8982-3-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 2/5] stash doc: document short form -p in synopsis","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:32:01Z","receivedAt":"2013-06-14T10:32:01Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"'git stash save' can take -p, the short form of --patch, as an option.\nDocument this.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-stash.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 83bb3db..08cdf2f 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n 'git stash' drop [-q|--quiet] [<stash>]\n 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]\n 'git stash' branch <branchname> [<stash>]\n-'git stash' [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]\n+'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n \t     [-u|--include-untracked] [-a|--all] [<message>]]\n 'git stash' clear\n 'git stash' create [<message>]\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220801","messageId":"1371205924-8982-4-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 3/5] stash: simplify option parser for create","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:32:02Z","receivedAt":"2013-06-14T10:32:02Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"The option parser for create unnecessarily checks \"$1\" inside a case\nstatement that matches \"$1\" in the first place.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n git-stash.sh | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex bbefdf6..64800b8 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -546,10 +546,7 @@ clear)\n \tclear_stash \"$@\"\n \t;;\n create)\n-\tif test $# -gt 0 && test \"$1\" = create\n-\tthen\n-\t\tshift\n-\tfi\n+\tshift\n \tcreate_stash \"$*\" && echo \"$w_commit\"\n \t;;\n drop)\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220800","messageId":"1371205924-8982-5-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 4/5] stash: introduce 'git stash store'","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:32:03Z","receivedAt":"2013-06-14T10:32:03Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"save_stash() contains the logic for doing two potentially independent\noperations; the first is preparing the stash merge commit, and the\nsecond is updating the stash ref/ reflog accordingly.  While the first\noperation is abstracted out into a create_stash() for callers to access\nvia 'git stash create', the second one is not.  Fix this by factoring\nout the logic for storing the stash into a store_stash() that callers\ncan access via 'git stash store'.\n\nLike create, store is not intended for end user interactive use, but for\ncallers in other scripts.  We can simplify the logic in the\nrebase.autostash feature using this new subcommand.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Documentation/git-stash.txt |  7 +++++++\n git-stash.sh                | 48 +++++++++++++++++++++++++++++++++++++++------\n t/t3903-stash.sh            | 19 ++++++++++++++++++\n 3 files changed, 68 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 08cdf2f..ec3a9a3 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -17,6 +17,7 @@ SYNOPSIS\n \t     [-u|--include-untracked] [-a|--all] [<message>]]\n 'git stash' clear\n 'git stash' create [<message>]\n+'git stash' store [-m|--message <message>] [-e|--error <message>] <commit>\n \n DESCRIPTION\n -----------\n@@ -153,6 +154,12 @@ create::\n \tobject name, without storing it anywhere in the ref namespace.\n \tThis is probably not what you want to use; see \"save\" above.\n \n+store::\n+\n+\tStore a given stash created via 'git stash create' (which is a\n+\tdangling merge commit) in the stash ref, updating the stash\n+\treflog.  This is probably not what you want to use; see\n+\t\"save\" above.\n \n DISCUSSION\n ----------\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 64800b8..7985473 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -156,6 +156,43 @@ create_stash () {\n \tdie \"$(gettext \"Cannot record working tree state\")\"\n }\n \n+store_stash () {\n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t-m|--message)\n+\t\t\tshift\n+\t\t\tstash_msg=\"$1\"\n+\t\t\t;;\n+\t\t-e|--error)\n+\t\t\tshift\n+\t\t\terror_msg=\"$1\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+\ttest $# == 1 ||\n+\tdie \"$(eval_gettext \"\\\"$dashless store\\\" requires one <commit> argument\")\"\n+\n+\tw_commit=\"$1\"\n+\tif test -z \"$stash_msg\"\n+\tthen\n+\t\tstash_msg=\"Created via \\\"git stash store\\\".\"\n+\tfi\n+\tif test -z \"$error_msg\"\n+\tthen\n+\t\terror_msg=\"Cannot update $ref_stash with $w_commit.\"\n+\tfi\n+\n+\t# Make sure the reflog for stash is kept.\n+\t: >>\"$GIT_DIR/logs/$ref_stash\"\n+\tgit update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n+\tdie \"$(eval_gettext \"$error_msg\")\"\n+}\n+\n save_stash () {\n \tkeep_index=\n \tpatch_mode=\n@@ -227,12 +264,7 @@ save_stash () {\n \t\tclear_stash || die \"$(gettext \"Cannot initialize stash\")\"\n \n \tcreate_stash \"$stash_msg\" $untracked\n-\n-\t# Make sure the reflog for stash is kept.\n-\t: >>\"$GIT_DIR/logs/$ref_stash\"\n-\n-\tgit update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n-\t\tdie \"$(gettext \"Cannot save the current status\")\"\n+\tstore_stash -m \"$stash_msg\" -e \"Cannot save the current status.\" $w_commit\n \tsay Saved working directory and index state \"$stash_msg\"\n \n \tif test -z \"$patch_mode\"\n@@ -549,6 +581,10 @@ create)\n \tshift\n \tcreate_stash \"$*\" && echo \"$w_commit\"\n \t;;\n+store)\n+\tshift\n+\tstore_stash \"$@\"\n+\t;;\n drop)\n \tshift\n \tdrop_stash \"$@\"\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 5dfbda7..75189ec 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -637,4 +637,23 @@ test_expect_success 'stash where working directory contains \"HEAD\" file' '\n \ttest_cmp output expect\n '\n \n+test_expect_success 'store called with invalid commit' '\n+\ttest_must_fail git stash store foo\n+'\n+\n+test_expect_success 'store updates stash ref and reflog' '\n+\tgit stash clear &&\n+\tgit reset --hard &&\n+\techo quux >bazzy &&\n+\tgit add bazzy &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit reset --hard &&\n+\t! grep quux bazzy &&\n+\tgit stash store -m quuxery $STASH_ID &&\n+\ttest $(cat .git/refs/stash) = $STASH_ID &&\n+\tgrep $STASH_ID .git/logs/refs/stash &&\n+\tgit stash pop &&\n+\tgrep quux bazzy\n+'\n+\n test_done\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220799","messageId":"1371205924-8982-6-git-send-email-artagnon@gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 5/5] rebase: use 'git stash store' to simplify logic","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T10:32:04Z","receivedAt":"2013-06-14T10:32:04Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"rebase has no reason to know about the implementation of the stash.  In\nthe case when applying the autostash results in conflicts, replace the\nrelevant code in finish_rebase () to simply call 'git stash store'.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n git-rebase.sh | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..bf37259 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -153,11 +153,7 @@ finish_rebase () {\n \t\tthen\n \t\t\techo \"$(gettext 'Applied autostash.')\"\n \t\telse\n-\t\t\tref_stash=refs/stash &&\n-\t\t\t>>\"$GIT_DIR/logs/$ref_stash\" &&\n-\t\t\tgit update-ref -m \"autostash\" $ref_stash $stash_sha1 ||\n-\t\t\tdie \"$(eval_gettext 'Cannot store $stash_sha1')\"\n-\n+\t\t\tgit stash store -m \"autostash\" -e \"Cannot store $stash_sha1.\" $stash_sha1\n \t\t\tgettext 'Applying autostash resulted in conflicts.\n Your changes are safe in the stash.\n You can run \"git stash pop\" or \"git stash drop\" it at any time.\n-- \n1.8.3.1.383.g0d5ad6b\n"},{"id":"220808","messageId":"CABURp0rF2ESFmvf=UQcbKr6ybc0wmGY-_=Nc3yMQJ2jhZGUQJQ@mail.gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-2-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 1/5] stash doc: add a warning about using create","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-06-14T12:27:46Z","receivedAt":"2013-06-14T12:27:46Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Fri, Jun 14, 2013 at 6:32 AM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Add a note saying that the user probably wants \"save\" in the create\n> description.  While at it, document that it can optionally take a\n> message in the synopsis.\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  Documentation/git-stash.txt | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\n> index 711ffe1..83bb3db 100644\n> --- a/Documentation/git-stash.txt\n> +++ b/Documentation/git-stash.txt\n> @@ -16,7 +16,7 @@ SYNOPSIS\n>  'git stash' [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]\n>              [-u|--include-untracked] [-a|--all] [<message>]]\n>  'git stash' clear\n> -'git stash' create\n> +'git stash' create [<message>]\n>\n>  DESCRIPTION\n>  -----------\n> @@ -151,6 +151,7 @@ create::\n>\n>         Create a stash (which is a regular commit object) and return its\n>         object name, without storing it anywhere in the ref namespace.\n> +       This is probably not what you want to use; see \"save\" above.\n\nThanks, this is helpful.\n\nMaybe you can also hint why this command exists.\n\n  +       This is intended to be useful for scripts.  It is probably not the\n  +       command you want to use; see \"save\" above.\n\n>\n>\n>  DISCUSSION\n> --\n> 1.8.3.1.383.g0d5ad6b\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"220810","messageId":"CABURp0rsP-Z7uT46WtSpVV7j4OGdcApcpDswsHt79V9WYbfCoQ@mail.gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-5-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 4/5] stash: introduce 'git stash store'","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-06-14T12:39:12Z","receivedAt":"2013-06-14T12:39:12Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Fri, Jun 14, 2013 at 6:32 AM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> save_stash() contains the logic for doing two potentially independent\n> operations; the first is preparing the stash merge commit, and the\n> second is updating the stash ref/ reflog accordingly.  While the first\n> operation is abstracted out into a create_stash() for callers to access\n> via 'git stash create', the second one is not.  Fix this by factoring\n> out the logic for storing the stash into a store_stash() that callers\n> can access via 'git stash store'.\n>\n> Like create, store is not intended for end user interactive use, but for\n> callers in other scripts.  We can simplify the logic in the\n> rebase.autostash feature using this new subcommand.\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  Documentation/git-stash.txt |  7 +++++++\n>  git-stash.sh                | 48 +++++++++++++++++++++++++++++++++++++++------\n>  t/t3903-stash.sh            | 19 ++++++++++++++++++\n>  3 files changed, 68 insertions(+), 6 deletions(-)\n>\n> diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\n> index 08cdf2f..ec3a9a3 100644\n> --- a/Documentation/git-stash.txt\n> +++ b/Documentation/git-stash.txt\n> @@ -17,6 +17,7 @@ SYNOPSIS\n>              [-u|--include-untracked] [-a|--all] [<message>]]\n>  'git stash' clear\n>  'git stash' create [<message>]\n> +'git stash' store [-m|--message <message>] [-e|--error <message>] <commit>\n>\n>  DESCRIPTION\n>  -----------\n> @@ -153,6 +154,12 @@ create::\n>         object name, without storing it anywhere in the ref namespace.\n>         This is probably not what you want to use; see \"save\" above.\n>\n> +store::\n> +\n> +       Store a given stash created via 'git stash create' (which is a\n> +       dangling merge commit) in the stash ref, updating the stash\n> +       reflog.  This is probably not what you want to use; see\n> +       \"save\" above.\n\nHere, again, I think you should explain more about this command.  Your\ncommit message explained it pretty well.\n\n  + Like create, store is intended to be useful for scripts.\n\n>\n>  DISCUSSION\n>  ----------\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 64800b8..7985473 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -156,6 +156,43 @@ create_stash () {\n>         die \"$(gettext \"Cannot record working tree state\")\"\n>  }\n>\n> +store_stash () {\n> +       while test $# != 0\n> +       do\n> +               case \"$1\" in\n> +               -m|--message)\n> +                       shift\n> +                       stash_msg=\"$1\"\n> +                       ;;\n> +               -e|--error)\n> +                       shift\n> +                       error_msg=\"$1\"\n> +                       ;;\n> +               *)\n> +                       break\n> +                       ;;\n> +               esac\n> +               shift\n> +       done\n> +       test $# == 1 ||\n> +       die \"$(eval_gettext \"\\\"$dashless store\\\" requires one <commit> argument\")\"\n> +\n> +       w_commit=\"$1\"\n> +       if test -z \"$stash_msg\"\n> +       then\n> +               stash_msg=\"Created via \\\"git stash store\\\".\"\n> +       fi\n> +       if test -z \"$error_msg\"\n> +       then\n> +               error_msg=\"Cannot update $ref_stash with $w_commit.\"\n> +       fi\n> +\n> +       # Make sure the reflog for stash is kept.\n> +       : >>\"$GIT_DIR/logs/$ref_stash\"\n> +       git update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n> +       die \"$(eval_gettext \"$error_msg\")\"\n> +}\n> +\n>  save_stash () {\n>         keep_index=\n>         patch_mode=\n> @@ -227,12 +264,7 @@ save_stash () {\n>                 clear_stash || die \"$(gettext \"Cannot initialize stash\")\"\n>\n>         create_stash \"$stash_msg\" $untracked\n> -\n> -       # Make sure the reflog for stash is kept.\n> -       : >>\"$GIT_DIR/logs/$ref_stash\"\n> -\n> -       git update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n> -               die \"$(gettext \"Cannot save the current status\")\"\n> +       store_stash -m \"$stash_msg\" -e \"Cannot save the current status.\" $w_commit\n\nnit: this adds a period to the end of the message which it did not\nhave previously.\n\n>         say Saved working directory and index state \"$stash_msg\"\n>\n>         if test -z \"$patch_mode\"\n> @@ -549,6 +581,10 @@ create)\n>         shift\n>         create_stash \"$*\" && echo \"$w_commit\"\n>         ;;\n> +store)\n> +       shift\n> +       store_stash \"$@\"\n> +       ;;\n>  drop)\n>         shift\n>         drop_stash \"$@\"\n> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n> index 5dfbda7..75189ec 100755\n> --- a/t/t3903-stash.sh\n> +++ b/t/t3903-stash.sh\n> @@ -637,4 +637,23 @@ test_expect_success 'stash where working directory contains \"HEAD\" file' '\n>         test_cmp output expect\n>  '\n>\n> +test_expect_success 'store called with invalid commit' '\n> +       test_must_fail git stash store foo\n> +'\n> +\n> +test_expect_success 'store updates stash ref and reflog' '\n> +       git stash clear &&\n> +       git reset --hard &&\n> +       echo quux >bazzy &&\n> +       git add bazzy &&\n> +       STASH_ID=$(git stash create) &&\n> +       git reset --hard &&\n> +       ! grep quux bazzy &&\n> +       git stash store -m quuxery $STASH_ID &&\n> +       test $(cat .git/refs/stash) = $STASH_ID &&\n> +       grep $STASH_ID .git/logs/refs/stash &&\n> +       git stash pop &&\n> +       grep quux bazzy\n> +'\n> +\n>  test_done\n> --\n> 1.8.3.1.383.g0d5ad6b\n\nLooks clean to me, but I didn't test it.\n\nPhil\n"},{"id":"220814","messageId":"CABURp0rEzKwE__Sg+Z66iOo7qZn0NKPzPuuhb52taBs8zyga=Q@mail.gmail.com","threadId":"34138","inReplyTo":"1371205924-8982-6-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 5/5] rebase: use 'git stash store' to simplify logic","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-06-14T12:47:54Z","receivedAt":"2013-06-14T12:47:54Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Fri, Jun 14, 2013 at 6:32 AM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> rebase has no reason to know about the implementation of the stash.  In\n> the case when applying the autostash results in conflicts, replace the\n> relevant code in finish_rebase () to simply call 'git stash store'.\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  git-rebase.sh | 6 +-----\n>  1 file changed, 1 insertion(+), 5 deletions(-)\n>\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index d0c11a9..bf37259 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n> @@ -153,11 +153,7 @@ finish_rebase () {\n>                 then\n>                         echo \"$(gettext 'Applied autostash.')\"\n>                 else\n> -                       ref_stash=refs/stash &&\n> -                       >>\"$GIT_DIR/logs/$ref_stash\" &&\n> -                       git update-ref -m \"autostash\" $ref_stash $stash_sha1 ||\n> -                       die \"$(eval_gettext 'Cannot store $stash_sha1')\"\n> -\n> +                       git stash store -m \"autostash\" -e \"Cannot store $stash_sha1.\" $stash_sha1\n\nnit: adds a period where there was not one previously.\n\nMaybe this doesn't matter so much since this code is new anyway.  But\nshowing a period after sha1 seems wrong, too. Or maybe I am confused\nagain.  Does eval_gettext routinely add a period to the end of\ntranslated strings?\n\n>                         gettext 'Applying autostash resulted in conflicts.\n>  Your changes are safe in the stash.\n>  You can run \"git stash pop\" or \"git stash drop\" it at any time.\n> --\n> 1.8.3.1.383.g0d5ad6b\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"220825","messageId":"CALkWK0n+f6xSfTCyxe+aY4vYq9Dhq5jFohmkXOuUkEVHv0FxCw@mail.gmail.com","threadId":"34138","inReplyTo":"CABURp0rEzKwE__Sg+Z66iOo7qZn0NKPzPuuhb52taBs8zyga=Q@mail.gmail.com","subject":"Re: [PATCH 5/5] rebase: use 'git stash store' to simplify logic","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T13:40:43Z","receivedAt":"2013-06-14T13:40:43Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Phil Hord wrote:\n> nit: adds a period where there was not one previously.\n\nStripped periods in both, thanks.\n"},{"id":"220867","messageId":"7va9mssr88.fsf@alter.siamese.dyndns.org","threadId":"34138","inReplyTo":"1371205924-8982-1-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH v2 0/5] Write a good 'git stash store' for autostash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-14T14:26:47Z","receivedAt":"2013-06-14T14:26:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> So, I've taken Junio's suggestion and designed a proper command-line\n> interface for 'git stash store' in this iteration:\n>\n>   git stash store [-m <message>] [-e <error>] <commit>\n\nI am perplexed; that would not something I _would_ design or\nsuggest.  The \"-e <error>\" looks especially odd, in that \"-e\"\nusually refers to something the command evaluates (e.g. sed, perl),\nbut more importantly if the caller wants a custom error message,\nnormal programmers would do\n\n\tcommand || die \"my custom error message\"\n\nand if \"command\" wants to show its own error by default, perhaps do\n\n\tcommand --quiet || die \"my custom error message\"\n"},{"id":"220874","messageId":"7vd2roralm.fsf@alter.siamese.dyndns.org","threadId":"34138","inReplyTo":"CABURp0rF2ESFmvf=UQcbKr6ybc0wmGY-_=Nc3yMQJ2jhZGUQJQ@mail.gmail.com","subject":"Re: [PATCH 1/5] stash doc: add a warning about using create","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-14T15:11:17Z","receivedAt":"2013-06-14T15:11:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n>>  DESCRIPTION\n>>  -----------\n>> @@ -151,6 +151,7 @@ create::\n>>\n>>         Create a stash (which is a regular commit object) and return its\n>>         object name, without storing it anywhere in the ref namespace.\n>> +       This is probably not what you want to use; see \"save\" above.\n>\n> Thanks, this is helpful.\n>\n> Maybe you can also hint why this command exists.\n>\n>   +       This is intended to be useful for scripts.  It is probably not the\n>   +       command you want to use; see \"save\" above.\n\nYeah, I agree that is much better than my original suggestion that\nresulted in the addition in this patch.\n\nThanks.\n"},{"id":"220877","messageId":"CALkWK0==4qMijvj+Xyt+e3dbRQjMMenNkMPZi1N78VHdrBQQsg@mail.gmail.com","threadId":"34138","inReplyTo":"7va9mssr88.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 0/5] Write a good 'git stash store' for autostash","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-14T15:16:36Z","receivedAt":"2013-06-14T15:16:36Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n>>   git stash store [-m <message>] [-e <error>] <commit>\n>\n> I am perplexed; that would not something I _would_ design or\n> suggest.  The \"-e <error>\" looks especially odd, in that \"-e\"\n> usually refers to something the command evaluates (e.g. sed, perl),\n> but more importantly if the caller wants a custom error message,\n> normal programmers would do\n>\n>         command || die \"my custom error message\"\n\nAnother result of me taking your suggestion too literally [1], and not\nusing my brains :/\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/224174\n"}]}