git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: feature request: add [-f|--from <rootbranch>] to git stash branch

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 14, 2022, 19:02 UTC
Message-ID
<xmqq8rvicf97.fsf@gitster.g>
In-Reply-To
<851ecd86-02d0-b078-1c90-ebe75ad46926@iee.email>
Philip Oakley <philipoakley@iee.email> writes:
Show 13 quoted lines
> Hi, some minor comments, in-line.
>
> On 13/01/2022 16:29, Colin Kennedy wrote:
>> Current syntax of git stash branch is:
>>
>> branch <branchname> [<stash>]
>>
>> Proposed syntax is:
>>
>> branch <branchname> [-f|--from <rootbranch>] [<stash>]
>
> Just to say that the `-f` is typically reserved/used for the --force
> option if available.
True.

Also, a dashed option and its argument should come before the non-dashed arguments, so if it were a good idea to introduce a new option, it should come after "git stash branch" and "<branchname>", not after "<branchname>".

Most importantly, this particular new option is unnecessary and is probably unwanted.

The original "git stash branch" relieves the user from finding out the commit where the stash was taken from, which is its value over its long-hand equivalent, i.e.

	git checkout -b <name> refs/stash^ &&
	git stash pop

The long-hand version forces the user to know that the first parent of the commit that represents a stash entry is the original commit the stash entry was taken from. With "git stash branch <name>", the user does not need to know it.

But the --from discards the only reason why "stash branch" subcommand needs to exist. It would be equivalent to

	git checkout -b <name> <rootbranch> &&
	git stash pop

and it is not helping the user, unlike the original that allowed the user to be oblivious to the internal implementation detail of a stash entry.

Or am I failing to see some obvious improvements over the longhand?

Worse, the application and discarding of the stash entry done by the "git stash branch" is guaranteed to apply cleanly, as we'd be applying the stash to its exact original state. The trees of <rootbranch> and refs/stash^, on the other hand, can be vastly different, and applying the stash on top of <rootbranch> commit can fail.

In short, I am not enthused.
Thanks.
Previous: Philip Oakley
Message 3 of 3 in “feature request: add [-f|--from <rootbranch>] to git stash branch”
  1. Colin KennedyJan 13, 2022
  2. Philip OakleyJan 14, 2022
  3. Junio C HamanoJan 14, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.