{"thread":{"id":"57235","subject":"feature request: add [-f|--from <rootbranch>] to git stash branch","startedAt":"2022-01-13T16:29:56Z","lastAt":"2022-01-14T19:02:34Z","messageCount":3,"participants":["Colin Kennedy","Philip Oakley","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"446159","messageId":"2a4f90e9-9abb-40b6-a6f3-a676567e4fc0@www.fastmail.com","threadId":"57235","inReplyTo":null,"subject":"feature request: add [-f|--from <rootbranch>] to git stash branch","fromName":"Colin Kennedy","fromEmail":"colin@mrkennedy.ca","sentAt":"2022-01-13T16:29:32Z","receivedAt":"2022-01-13T16:29:56Z","isPatch":false,"sender":{"key":"colin@mrkennedy.ca","avatar":null},"body":"Current syntax of git stash branch is:\n\nbranch <branchname> [<stash>]\n\nProposed syntax is:\n\nbranch <branchname> [-f|--from <rootbranch>] [<stash>]\n\nthe from flag specifies a branch from which the new branch should be derived.\n\nExample usage:\n\ngit stash branch remove-commented-code --from main\n\nThis simplifies a workflow which is common for me. I am working N-commits deep in some feature branch when I discover a low hanging fruit. Dealing with this low hanging fruit is not appropriate for the current feature branch. It's most appropriate to deal with \"directly\" on a fresh branch from main. Because I am untidy, I often have a bit of mess in between my staging area, and unstaged changes, and this creates friction when I attempt to stash this low hanging fruit, pop back to main, create the new branch, pop the stashed low hanging fruit, etc etc.\n\nThe proposed flag gives a one-liner to apply stashed patches wherever, no matter your current location, which I think is an improvement.\n\nHappy to have feedback on the flag. Happy for someone else to implement it. Also happy to consider taking a crack at it myself if it seems like something people would be happy to include. (NB: I haven't written or even read any c, or c++ for that matter, in probably 15 years. So, you know).\n\nthanks,\nColin\n"},{"id":"446219","messageId":"851ecd86-02d0-b078-1c90-ebe75ad46926@iee.email","threadId":"57235","inReplyTo":"2a4f90e9-9abb-40b6-a6f3-a676567e4fc0@www.fastmail.com","subject":"Re: feature request: add [-f|--from <rootbranch>] to git stash branch","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2022-01-14T14:53:51Z","receivedAt":"2022-01-14T14:53:53Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi, some minor comments, in-line.\n\nOn 13/01/2022 16:29, Colin Kennedy wrote:\n> Current syntax of git stash branch is:\n>\n> branch <branchname> [<stash>]\n>\n> Proposed syntax is:\n>\n> branch <branchname> [-f|--from <rootbranch>] [<stash>]\n\nJust to say that the `-f` is typically reserved/used for the --force\noption if available.\n>\n> the from flag specifies a branch from which the new branch should be derived.\n>\n> Example usage:\n>\n> git stash branch remove-commented-code --from main\n>\n> This simplifies a workflow which is common for me. I am working N-commits deep in some feature branch when I discover a low hanging fruit. Dealing with this low hanging fruit is not appropriate for the current feature branch. It's most appropriate to deal with \"directly\" on a fresh branch from main. Because I am untidy, \nMaybe an example that shows the level of untidiness might help to\nclarify the suggestion, as to what is included/not included, and how it\nmakes it easy later when the stash is recovered.\n\n> I often have a bit of mess in between my staging area, and unstaged changes, and this creates friction when I attempt to stash this low hanging fruit, pop back to main, create the new branch, pop the stashed low hanging fruit, etc etc.\n>\n> The proposed flag gives a one-liner to apply stashed patches wherever, no matter your current location, which I think is an improvement.\n>\n> Happy to have feedback on the flag. Happy for someone else to implement it. Also happy to consider taking a crack at it myself if it seems like something people would be happy to include. (NB: I haven't written or even read any c, or c++ for that matter, in probably 15 years. So, you know).\n>\n> thanks,\n> Colin\n\n"},{"id":"446236","messageId":"xmqq8rvicf97.fsf@gitster.g","threadId":"57235","inReplyTo":"851ecd86-02d0-b078-1c90-ebe75ad46926@iee.email","subject":"Re: feature request: add [-f|--from <rootbranch>] to git stash branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-14T19:02:28Z","receivedAt":"2022-01-14T19:02:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philip Oakley <philipoakley@iee.email> writes:\n\n> Hi, some minor comments, in-line.\n>\n> On 13/01/2022 16:29, Colin Kennedy wrote:\n>> Current syntax of git stash branch is:\n>>\n>> branch <branchname> [<stash>]\n>>\n>> Proposed syntax is:\n>>\n>> branch <branchname> [-f|--from <rootbranch>] [<stash>]\n>\n> Just to say that the `-f` is typically reserved/used for the --force\n> option if available.\n\nTrue.\n\nAlso, a dashed option and its argument should come before the\nnon-dashed arguments, so if it were a good idea to introduce a new\noption, it should come after \"git stash branch\" and \"<branchname>\",\nnot after \"<branchname>\".\n\nMost importantly, this particular new option is unnecessary and\nis probably unwanted.\n\nThe original \"git stash branch\" relieves the user from finding out\nthe commit where the stash was taken from, which is its value over\nits long-hand equivalent, i.e.\n\n\tgit checkout -b <name> refs/stash^ &&\n\tgit stash pop\n\nThe long-hand version forces the user to know that the first parent\nof the commit that represents a stash entry is the original commit\nthe stash entry was taken from.  With \"git stash branch <name>\", the\nuser does not need to know it.\n\nBut the --from discards the only reason why \"stash branch\" subcommand\nneeds to exist.  It would be equivalent to\n\n\tgit checkout -b <name> <rootbranch> &&\n\tgit stash pop\n\nand it is not helping the user, unlike the original that allowed the\nuser to be oblivious to the internal implementation detail of a\nstash entry.\n\nOr am I failing to see some obvious improvements over the longhand?\n\nWorse, the application and discarding of the stash entry done by the\n\"git stash branch\" is guaranteed to apply cleanly, as we'd be\napplying the stash to its exact original state.  The trees of\n<rootbranch> and refs/stash^, on the other hand, can be vastly\ndifferent, and applying the stash on top of <rootbranch> commit can\nfail.\n\nIn short, I am not enthused.\n\nThanks.\n"}]}