git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Philip Oakley <philipoakley@iee.email>
Cc: Colin Kennedy <colin@mrkennedy.ca>, git@vger.kernel.org
Subject: Re: feature request: add [-f|--from <rootbranch>] to git stash branch
Date: Fri, 14 Jan 2022 11:02:28 -0800	[thread overview]
Message-ID: <xmqq8rvicf97.fsf@gitster.g> (raw)
In-Reply-To: <851ecd86-02d0-b078-1c90-ebe75ad46926@iee.email> (Philip Oakley's message of "Fri, 14 Jan 2022 14:53:51 +0000")

Philip Oakley <philipoakley@iee.email> writes:

> 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.

      reply	other threads:[~2022-01-14 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 16:29 feature request: add [-f|--from <rootbranch>] to git stash branch Colin Kennedy
2022-01-14 14:53 ` Philip Oakley
2022-01-14 19:02   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8rvicf97.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=colin@mrkennedy.ca \
    --cc=git@vger.kernel.org \
    --cc=philipoakley@iee.email \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).