Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
`rad init` default branch uses current reference
Closed { reason: Solved } fintohaps opened 1 year ago

I was watching someone use rad init recently, and they had to stop for a second when they were choosing the default branch and it pointed to HEAD.

This seems confusing and it might be better to use Git’s underlying configuration value for default branches.

stemporus commented 1 year ago

Do you mean, when the user specifies a default branch it should use current head for a branch matching that name as stored in .git/refs/heads?

i.e.:

rad init --default-branch master

will initialize radicle repository with a default branch named master using the commit current pointed to in .git/refs/heads/master?

if so,

  • what should happen if the default branch name specified does not exist?
    • default to the current behaviour of HEAD? or just error to the user, telling them they need to pick an existing branch?
    • What about in the case of repository not having any refs?
fintohaps commented 1 year ago

No, sorry perhaps I wasn’t clear. When you call rad init theres a wizard setup, where it prompts you title, description, default branch, and visibility.

When it comes to prompting you with the default branch, it will use the current reference you’re on. If you use jj, like me, there’s a high chance you’ll be in a detached head state, and so the default reference will be HEAD. I’m proposing we use the user’s config value – if it is set – instead.

To answer your questions:

what should happen if the default branch name specified does not exist?

It will error

What about in the case of repository not having any refs?

It will also error :)

stemporus commented 1 year ago

Would you be looking for something akin to what I have in this draft patch?

rad patch show 058586b3b44ce80f534b8ec82b730dd91e1df32d
z6MkgFq6...nBGz commented 7 months ago

The patch was merged, so closing this now.