Subject: Re: changing the experimental 'git switch'

From: Junio C Hamano <[email-masked]>
Date: Sun, 24 Oct 2021 13:27:34 -0700

Martin <[email-masked]> 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.