{"thread":{"id":"52794","subject":"[PATCH] [RFC PATCH] stash save/push: add --index-only option","startedAt":"2020-02-12T23:50:52Z","lastAt":"2020-02-13T17:12:57Z","messageCount":6,"participants":["Edmundo Carmona Antoranz","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"391631","messageId":"20200212235033.782656-1-eantoranz@gmail.com","threadId":"52794","inReplyTo":null,"subject":"[PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2020-02-12T23:50:33Z","receivedAt":"2020-02-12T23:50:52Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Allow git-stash to save only the content of what's in staging area.\nNo working tree files (unstaged or untracked) will be added\nto the stash nor will be modified then the opreration finishes.\n\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n builtin/stash.c | 115 ++++++++++++++++++++++++++++++------------------\n 1 file changed, 72 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 879fc5f368..d96b849965 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -27,9 +27,10 @@ static const char * const git_stash_usage[] = {\n \tN_(\"git stash clear\"),\n \tN_(\"git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\\n\"\n \t   \"          [-u|--include-untracked] [-a|--all] [-m|--message <message>]\\n\"\n-\t   \"          [--] [<pathspec>...]]\"),\n+\t   \"          [-i|--index-only] [--] [<pathspec>...]]\"),\n \tN_(\"git stash save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\\n\"\n-\t   \"          [-u|--include-untracked] [-a|--all] [<message>]\"),\n+\t   \"          [-u|--include-untracked] [-a|--all]\\n\"\n+\t   \"          [-i|--index-only] [<message>]\"),\n \tNULL\n };\n \n@@ -76,13 +77,14 @@ static const char * const git_stash_store_usage[] = {\n static const char * const git_stash_push_usage[] = {\n \tN_(\"git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\\n\"\n \t   \"          [-u|--include-untracked] [-a|--all] [-m|--message <message>]\\n\"\n-\t   \"          [--] [<pathspec>...]]\"),\n+\t   \"          [-i|--index-only] [--] [<pathspec>...]]\"),\n \tNULL\n };\n \n static const char * const git_stash_save_usage[] = {\n \tN_(\"git stash save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\\n\"\n-\t   \"          [-u|--include-untracked] [-a|--all] [<message>]\"),\n+\t   \"          [-u|--include-untracked] [-i|--index-only] [-a|--all]\\n\"\n+\t   \"          [<message>]\"),\n \tNULL\n };\n \n@@ -1055,7 +1057,7 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,\n \treturn ret;\n }\n \n-static int stash_working_tree(struct stash_info *info, const struct pathspec *ps)\n+static int stash_working_tree(struct stash_info *info, const struct pathspec *ps, int index_only)\n {\n \tint ret = 0;\n \tstruct rev_info rev;\n@@ -1089,17 +1091,20 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps\n \t\tgoto done;\n \t}\n \n-\tcp_upd_index.git_cmd = 1;\n-\targv_array_pushl(&cp_upd_index.args, \"update-index\",\n-\t\t\t \"--ignore-skip-worktree-entries\",\n-\t\t\t \"-z\", \"--add\", \"--remove\", \"--stdin\", NULL);\n-\targv_array_pushf(&cp_upd_index.env_array, \"GIT_INDEX_FILE=%s\",\n-\t\t\t stash_index_path.buf);\n-\n-\tif (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,\n-\t\t\t NULL, 0, NULL, 0)) {\n-\t\tret = -1;\n-\t\tgoto done;\n+\tif (!index_only) {\n+\t\tcp_upd_index.git_cmd = 1;\n+\t\targv_array_pushl(&cp_upd_index.args, \"update-index\",\n+\t\t\t\t\"--ignore-skip-worktree-entries\",\n+\t\t\t\t\"-z\", \"--add\", \"--remove\", \"--stdin\", NULL);\n+\t\targv_array_pushf(&cp_upd_index.env_array, \"GIT_INDEX_FILE=%s\",\n+\t\t\t\tstash_index_path.buf);\n+\n+\t\tif (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len,\n+\t\t\t\tNULL, 0, NULL, 0)) {\n+\t\t\tprintf(\"salimos por pipe_command\\n\");\n+\t\t\tret = -1;\n+\t\t\tgoto done;\n+\t\t}\n \t}\n \n \tif (write_index_as_tree(&info->w_tree, &istate, stash_index_path.buf, 0,\n@@ -1119,7 +1124,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps\n }\n \n static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_buf,\n-\t\t\t   int include_untracked, int patch_mode,\n+\t\t\t   int include_untracked, int index_only, int patch_mode,\n \t\t\t   struct stash_info *info, struct strbuf *patch,\n \t\t\t   int quiet)\n {\n@@ -1199,7 +1204,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b\n \t\t\tgoto done;\n \t\t}\n \t} else {\n-\t\tif (stash_working_tree(info, ps)) {\n+\t\tif (stash_working_tree(info, ps, index_only)) {\n \t\t\tif (!quiet)\n \t\t\t\tfprintf_ln(stderr, _(\"Cannot save the current \"\n \t\t\t\t\t\t     \"worktree state\"));\n@@ -1256,7 +1261,7 @@ static int create_stash(int argc, const char **argv, const char *prefix)\n \tif (!check_changes_tracked_files(&ps))\n \t\treturn 0;\n \n-\tret = do_create_stash(&ps, &stash_msg_buf, 0, 0, &info,\n+\tret = do_create_stash(&ps, &stash_msg_buf, 0, 0, 0, &info,\n \t\t\t      NULL, 0);\n \tif (!ret)\n \t\tprintf_ln(\"%s\", oid_to_hex(&info.w_commit));\n@@ -1266,7 +1271,8 @@ static int create_stash(int argc, const char **argv, const char *prefix)\n }\n \n static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int quiet,\n-\t\t\t int keep_index, int patch_mode, int include_untracked)\n+\t\t\t int keep_index, int patch_mode, int include_untracked,\n+\t\t\t int index_only)\n {\n \tint ret = 0;\n \tstruct stash_info info;\n@@ -1283,9 +1289,16 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \t\tret = -1;\n \t\tgoto done;\n \t}\n+\t\n+\tif (include_untracked && index_only) {\n+\t\tfprintf_ln(stderr, _(\"Can't use --index_only and --include-untracked\"\n+\t\t\t\t     \" at the same time\")); // TODO how about --all?\n+\t\tret = -1;\n+\t\tgoto done;\n+\t}\n \n \tread_cache_preload(NULL);\n-\tif (!include_untracked && ps->nr) {\n+\tif (!include_untracked && !index_only && ps->nr) {\n \t\tint i;\n \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n \n@@ -1322,8 +1335,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \n \tif (stash_msg)\n \t\tstrbuf_addstr(&stash_msg_buf, stash_msg);\n-\tif (do_create_stash(ps, &stash_msg_buf, include_untracked, patch_mode,\n-\t\t\t    &info, &patch, quiet)) {\n+\tif (do_create_stash(ps, &stash_msg_buf, include_untracked, index_only,\n+\t\t\t    patch_mode, &info, &patch, quiet)) {\n \t\tret = -1;\n \t\tgoto done;\n \t}\n@@ -1335,9 +1348,14 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \t\tgoto done;\n \t}\n \n-\tif (!quiet)\n-\t\tprintf_ln(_(\"Saved working directory and index state %s\"),\n-\t\t\t  stash_msg_buf.buf);\n+\tif (!quiet) {\n+\t\tif (index_only)\n+\t\t\tprintf_ln(_(\"Saved index state %s\"),\n+\t\t\t\tstash_msg_buf.buf);\n+\t\telse\n+\t\t\tprintf_ln(_(\"Saved working directory and index state %s\"),\n+\t\t\t\tstash_msg_buf.buf);\n+\t}\n \n \tif (!patch_mode) {\n \t\tif (include_untracked && !ps->nr) {\n@@ -1354,30 +1372,34 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \t\t\t}\n \t\t}\n \t\tdiscard_cache();\n-\t\tif (ps->nr) {\n-\t\t\tstruct child_process cp_add = CHILD_PROCESS_INIT;\n+\t\tif (index_only || ps->nr) {\n \t\t\tstruct child_process cp_diff = CHILD_PROCESS_INIT;\n \t\t\tstruct child_process cp_apply = CHILD_PROCESS_INIT;\n \t\t\tstruct strbuf out = STRBUF_INIT;\n \n-\t\t\tcp_add.git_cmd = 1;\n-\t\t\targv_array_push(&cp_add.args, \"add\");\n-\t\t\tif (!include_untracked)\n-\t\t\t\targv_array_push(&cp_add.args, \"-u\");\n-\t\t\tif (include_untracked == INCLUDE_ALL_FILES)\n-\t\t\t\targv_array_push(&cp_add.args, \"--force\");\n-\t\t\targv_array_push(&cp_add.args, \"--\");\n-\t\t\tadd_pathspecs(&cp_add.args, ps);\n-\t\t\tif (run_command(&cp_add)) {\n-\t\t\t\tret = -1;\n-\t\t\t\tgoto done;\n+\t\t\tif (!index_only) {\n+\t\t\t\tstruct child_process cp_add = CHILD_PROCESS_INIT;\n+\n+\t\t\t\tcp_add.git_cmd = 1;\n+\t\t\t\targv_array_push(&cp_add.args, \"add\");\n+\t\t\t\tif (!include_untracked)\n+\t\t\t\t\targv_array_push(&cp_add.args, \"-u\");\n+\t\t\t\tif (include_untracked == INCLUDE_ALL_FILES)\n+\t\t\t\t\targv_array_push(&cp_add.args, \"--force\");\n+\t\t\t\targv_array_push(&cp_add.args, \"--\");\n+\t\t\t\tadd_pathspecs(&cp_add.args, ps);\n+\t\t\t\tif (run_command(&cp_add)) {\n+\t\t\t\t\tret = -1;\n+\t\t\t\t\tgoto done;\n+\t\t\t\t}\n \t\t\t}\n \n \t\t\tcp_diff.git_cmd = 1;\n \t\t\targv_array_pushl(&cp_diff.args, \"diff-index\", \"-p\",\n \t\t\t\t\t \"--cached\", \"--binary\", \"HEAD\", \"--\",\n \t\t\t\t\t NULL);\n-\t\t\tadd_pathspecs(&cp_diff.args, ps);\n+\t\t\tif (!index_only)\n+\t\t\t\tadd_pathspecs(&cp_diff.args, ps);\n \t\t\tif (pipe_command(&cp_diff, NULL, 0, &out, 0, NULL, 0)) {\n \t\t\t\tret = -1;\n \t\t\t\tgoto done;\n@@ -1391,7 +1413,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \t\t\t\tret = -1;\n \t\t\t\tgoto done;\n \t\t\t}\n-\t\t} else {\n+\t\t} else if (!index_only) {\n \t\t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \t\t\tcp.git_cmd = 1;\n \t\t\targv_array_pushl(&cp.args, \"reset\", \"--hard\", \"-q\",\n@@ -1456,6 +1478,7 @@ static int push_stash(int argc, const char **argv, const char *prefix)\n \tint keep_index = -1;\n \tint patch_mode = 0;\n \tint include_untracked = 0;\n+\tint index_only = 0;\n \tint quiet = 0;\n \tconst char *stash_msg = NULL;\n \tstruct pathspec ps;\n@@ -1467,6 +1490,8 @@ static int push_stash(int argc, const char **argv, const char *prefix)\n \t\tOPT__QUIET(&quiet, N_(\"quiet mode\")),\n \t\tOPT_BOOL('u', \"include-untracked\", &include_untracked,\n \t\t\t N_(\"include untracked files in stash\")),\n+\t\tOPT_BOOL('i', \"index-only\", &index_only,\n+\t\t\t N_(\"stash only what is in staging area\")),\n \t\tOPT_SET_INT('a', \"all\", &include_untracked,\n \t\t\t    N_(\"include ignore files\"), 2),\n \t\tOPT_STRING('m', \"message\", &stash_msg, N_(\"message\"),\n@@ -1482,7 +1507,7 @@ static int push_stash(int argc, const char **argv, const char *prefix)\n \tparse_pathspec(&ps, 0, PATHSPEC_PREFER_FULL | PATHSPEC_PREFIX_ORIGIN,\n \t\t       prefix, argv);\n \treturn do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode,\n-\t\t\t     include_untracked);\n+\t\t\t     include_untracked, index_only);\n }\n \n static int save_stash(int argc, const char **argv, const char *prefix)\n@@ -1490,6 +1515,7 @@ static int save_stash(int argc, const char **argv, const char *prefix)\n \tint keep_index = -1;\n \tint patch_mode = 0;\n \tint include_untracked = 0;\n+\tint index_only = 0;\n \tint quiet = 0;\n \tint ret = 0;\n \tconst char *stash_msg = NULL;\n@@ -1503,6 +1529,8 @@ static int save_stash(int argc, const char **argv, const char *prefix)\n \t\tOPT__QUIET(&quiet, N_(\"quiet mode\")),\n \t\tOPT_BOOL('u', \"include-untracked\", &include_untracked,\n \t\t\t N_(\"include untracked files in stash\")),\n+\t\tOPT_BOOL('i', \"index-only\", &index_only,\n+\t\t\t N_(\"stash only what is in staging area\")),\n \t\tOPT_SET_INT('a', \"all\", &include_untracked,\n \t\t\t    N_(\"include ignore files\"), 2),\n \t\tOPT_STRING('m', \"message\", &stash_msg, \"message\",\n@@ -1519,7 +1547,7 @@ static int save_stash(int argc, const char **argv, const char *prefix)\n \n \tmemset(&ps, 0, sizeof(ps));\n \tret = do_push_stash(&ps, stash_msg, quiet, keep_index,\n-\t\t\t    patch_mode, include_untracked);\n+\t\t\t    patch_mode, include_untracked, index_only);\n \n \tstrbuf_release(&stash_msg_buf);\n \treturn ret;\n@@ -1625,6 +1653,7 @@ int cmd_stash(int argc, const char **argv, const char *prefix)\n \t\t\t    !strcmp(argv[i], \"--no-keep-index\") ||\n \t\t\t    !strcmp(argv[i], \"--patch\") ||\n \t\t\t    !strcmp(argv[i], \"--quiet\") ||\n+\t\t\t    !strcmp(argv[i], \"--index-only\") ||\n \t\t\t    !strcmp(argv[i], \"--include-untracked\"))\n \t\t\t\tcontinue;\n \n-- \n2.24.1\n\n"},{"id":"391632","messageId":"CAOc6etbkMJf9qSNMU4fD4KeHE6NuMRUuQf_cBos_oxuYwaaeAA@mail.gmail.com","threadId":"52794","inReplyTo":"20200212235033.782656-1-eantoranz@gmail.com","subject":"Re: [PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2020-02-12T23:52:59Z","receivedAt":"2020-02-12T23:53:14Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Wed, Feb 12, 2020 at 5:50 PM Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n>\n> Allow git-stash to save only the content of what's in staging area.\n> No working tree files (unstaged or untracked) will be added\n> to the stash nor will be modified then the opreration finishes.\n>\n\nSorry for the double tag. This is not fully completed code. Wanted to\nknow if the community thinks it's something worth developing and if\nI'm heading in the right direction in terms of the code that I'm\nhitting.\n\nThanks!\n"},{"id":"391649","messageId":"xmqqblq3t6w1.fsf@gitster-ct.c.googlers.com","threadId":"52794","inReplyTo":"CAOc6etbkMJf9qSNMU4fD4KeHE6NuMRUuQf_cBos_oxuYwaaeAA@mail.gmail.com","subject":"Re: [PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-13T05:04:30Z","receivedAt":"2020-02-13T05:04:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:\n\n> On Wed, Feb 12, 2020 at 5:50 PM Edmundo Carmona Antoranz\n> <eantoranz@gmail.com> wrote:\n>>\n>> Allow git-stash to save only the content of what's in staging area.\n>> No working tree files (unstaged or untracked) will be added\n>> to the stash nor will be modified then the opreration finishes.\n>>\n>\n> Sorry for the double tag. This is not fully completed code. Wanted to\n> know if the community thinks it's something worth developing and if\n> I'm heading in the right direction in terms of the code that I'm\n> hitting.\n\nI am not sure if you explained how useful the \"feature\" being\nproposed is, which is a very important skill to exercise to entice\nreaders to start reading and helping your code.\n\nWhy is it useful to be able to do this?  It is unclear at least to\nme.\n\nBy the way, per \"git help cli\", the name for this new option that is\nmore in line with the rest of the system would be \"--cached\"; it\nwould tell Git to work only on the data in the index (as opposed to\nthe working tree files).\n.\n\n"},{"id":"391659","messageId":"CAOc6etYA79mTHB595cCVphmYmFECYvgPgV09SNo-pdEPEVD37w@mail.gmail.com","threadId":"52794","inReplyTo":"xmqqblq3t6w1.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2020-02-13T13:21:54Z","receivedAt":"2020-02-13T13:22:07Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Wed, Feb 12, 2020 at 11:04 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> I am not sure if you explained how useful the \"feature\" being\n> proposed is, which is a very important skill to exercise to entice\n> readers to start reading and helping your code.\n>\n> Why is it useful to be able to do this?  It is unclear at least to\n> me.\n\nFair enough. It's ok to explain here, right? There's no simple way to stash only\nwhat you have on index while retaining your working tree state.\n\nI would do this to achieve it:\nsave what I have on the index somehow\n$ git commit -m \"will drop this revision later\"\n\nthat revision I just created has what I want to stash, actually\n\n$ git stash save -m \"want to keep this on working tree when I finish\"\n\nmy work tree is now clean (perhaps with untracked files)\n\n$ git reset soft HEAD~1 # get what I had on index before\n\nnow I can stash... this is what I originally intended\n\n$ git stash save -m \"what I really meant to stash\"\n\nand now I need to get the working tree the way I had it when I started:\n\ngit stash pop stash@{1}\n\n\nAll of that with git stash push --index-only... well, git stash push --cached\n\n>\n> By the way, per \"git help cli\", the name for this new option that is\n> more in line with the rest of the system would be \"--cached\"; it\n> would tell Git to work only on the data in the index (as opposed to\n> the working tree files).\n> .\n>\n"},{"id":"391671","messageId":"xmqqr1yys9ze.fsf@gitster-ct.c.googlers.com","threadId":"52794","inReplyTo":"CAOc6etYA79mTHB595cCVphmYmFECYvgPgV09SNo-pdEPEVD37w@mail.gmail.com","subject":"Re: [PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-13T16:55:17Z","receivedAt":"2020-02-13T16:55:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:\n\n> Fair enough. It's ok to explain here, right?\n\nYes, absolutely.   How it works is \n\n - an author comes up with a patch and its explanation and\n   justificaiton, \n\n - reviewers ask clarifications on what was unclear, point out what\n   was wrong in the code, etc., and then \n\n - the author responds with \"here is what I meant\", \"yeah, you're\n   right that the code is wrong--would it be right to write it this\n   way?\", and/or \"not really, the code is OK because ...\", etc.\n\nAll that exchange is to come up with a more polished version that\nhas correct code that is explained and justified in a clear manner.\n\nThe next iteration the author then sends would of course include the\nfixes to bugs pointed out during the review, but also would explain\nand justify the change better---the explanation in the original did\nnot convey what the author wanted to tell, but the explanation the\nauthor gave during the review discussion did so better, so the new\niteration can learn from that exchange.\n\n> There's no simple way to stash only\n> what you have on index while retaining your working tree state.\n\nYes, that much can be inferred from what it does (\"there is no easy\nway to do X, so I am adding X\").\n\nThe question is why would one want to do X in the first place.\n\nIIUC, the simplest workflow using the new feature may go like this:\n\n\t$ edit file ;# edit a bit\n\t$ git add file\n\t$ edit file ;# even even more\n\t$ git stash --cached\n\nAfter all of the above is done, \"git stash list\" may show that there\nis a single stash that records the changes you made to the file\nright after you added it, without your further changes (because you\nare taking what is in the index).  Your working tree has all the\nchanges you made to file, both before and after \"git add\", and your\nindex is clean.\n\nAfter you got yourself into this state where your index is clean,\nyour working tree file has all changes, and your stash entry has\nonly the earlier half of the change, what are you going to do with\nthat stash entry?  If we learn the answer to that question, perhaps\nwe may find (or we may even have) a better or easier way to achieve\nwhatever you were planning to do with that stash entry by some other\nmeans---it might not even involve \"git stash\"---but without knowing\nthat, we cannot tell if the new feature is a good idea.\n\nThanks.\n"},{"id":"391672","messageId":"CAOc6etYQPi6ghjVGdUc8Mk6oD946-YL35rJ3f9wKFSy74F450A@mail.gmail.com","threadId":"52794","inReplyTo":"xmqqr1yys9ze.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] [RFC PATCH] stash save/push: add --index-only option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2020-02-13T17:12:43Z","receivedAt":"2020-02-13T17:12:57Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Thu, Feb 13, 2020 at 10:55 AM Junio C Hamano <gitster@pobox.com> wrote:\n> IIUC, the simplest workflow using the new feature may go like this:\n>\n>         $ edit file ;# edit a bit\n>         $ git add file\n>         $ edit file ;# even even more\n>         $ git stash --cached\n>\n> After all of the above is done, \"git stash list\" may show that there\n> is a single stash that records the changes you made to the file\n> right after you added it, without your further changes (because you\n> are taking what is in the index).  Your working tree has all the\n> changes you made to file, both before and after \"git add\", and your\n> index is clean.\n>\n> After you got yourself into this state where your index is clean,\n> your working tree file has all changes, and your stash entry has\n> only the earlier half of the change, what are you going to do with\n> that stash entry?  If we learn the answer to that question, perhaps\n> we may find (or we may even have) a better or easier way to achieve\n> whatever you were planning to do with that stash entry by some other\n> means---it might not even involve \"git stash\"---but without knowing\n> that, we cannot tell if the new feature is a good idea.\n\nActually, let this conversation burn in /dev/null. What I want to\nachieve (stash only some changes and not all of them) can be done by\nusing git stash push providing pathspec.\n\n>\n> Thanks.\n\nThank you!\n"}]}