Re: changing the experimental 'git switch'
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Oct 25, 2021, 12:48 UTC
- Message-ID
- <211025.86tuh5gtcc.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <xmqqwnm2418p.fsf@gitster.g>
On Sun, Oct 24 2021, Junio C Hamano wrote:
Show 42 quoted lines
> Martin <git@mfriebe.de> writes:
>
>> So one could do
>> git switch --settings-from <branch-with-reflog-and-conf> --create
>> <new-branch> <commit>
>> git switch -s <branch-with-reflog-and-conf> -c <new-branch> <commit>
>>
>> "settings-from" is just an example, there may be better names for
>> it. Ideally not starting with a "c".
>>
>> And using a name different from "copy" may be more accurate, because
>> unless it is created on the same one <commit> to which the
>> <branch-with-reflog-and-conf> points, then its at best partially copied.
>
> I like the "copy the settings from this other branch when creating
> this new branch" as a concept.
>
> One thing that I find iffy is the reflog. Even with the current
> "create a new branch NEW, pointing at the same commit, tracking the
> same remote-tracking branch, having the same branch description, and
> pretending to have come along the same trajectory, out of this
> original branch OLD", I actually find that the copyng of reflog is
> utterly questionable. Before that operation, the new branch did not
> exist, hence NEW@{4.days.ago} shouldn't say the same thing as
> OLD@{4.days.ago} for the branch NEW that was created like so just a
> minute ago.
>
> If you generalize the operation to allow starting the new branch at
> a different commit, it becomes even more strange to copy the reflog
> of the "original" branch, which is not even the original for this
> new branch.
>
> Another thing nobody seems to have brought up is the branch
> description. We copy everything under branch.OLD.* to branch.NEW.*
> and end up copying it from OLD to NEW, but I think that is also a
> nonsense operation.
>
> So, it probably makes sense to be more selective that what are
> sensibly copied and what are not. Reflog most likely does not
> belong to the "sensibly copyable" set. Tracking info most likely
> does. Among various configuration in branch.OLD.*, there may be
> things like description that are not sensibly copyable.It is a bit weird, but the main problem is that we'll use it for UI such as @{-1} or whatever in addition to things like "x days ago". So if you copy a branch for some ad-hoc testing, and were just running such a command you might expend it to work.
For a user it also maps nicely to the mental model you'd have if you copied two directories with the "-p" option to "cp", i.e. you'll be able to run a "find" command on that checking mtime of N days ago and the like.
Maybe it still doesn't make sense for those cases just some thoughts on UX edge cases.