4 ms·
Looks interesting, thanks for writing and posting. I would suggest you go further and package all the branch related operations as subcommands of "gut branch".
by mhalle 4y ago
Looks interesting, thanks for writing and posting.
I would suggest you go further and package all the branch related operations as subcommands of "gut branch". For instance, "gut branch ls" is more transparent and explicit than just "gut branch".
Also move the "switch" commands to "branch". Force branch creation to be explicit ("gut branch new") that does not change the current branch. That will prevent typos or memory lapses from leading to errant new branches. Then provide "gut branch switch branchname" that will only switch to an existing branch. You can include a "-f" flag to explicitly force branch creation, allowing a single command "create and switch" operation. You have in general avoided flags, but "-f" is extremely common and widely understood in the unix world.
Small changes like these can make significant improvements in the ergonomics of an interface that is already better than git's.
- julien040 4y agoThank you for pointing this out. "gut branch ls" is an alias of "gut branch", and to prevent unwanted branch creation, a confirmation prompt appears when a new branch is specified in "gut switch". I still agree with your point, though; it would be more consistent to have everything under the "branch" command. I will consider these changes.
- memco 4y ago> Also move the "switch" commands to "branch". In git you can switch to a tag or commit in addition to a branch. There are different flags you may want to use depending on which type of ref you have so in the case that gut should only support switching branches moving the command may make sense, but if it supports arbitrary refs then moving it would not make sense. Looking at the switch code for gut `CheckIfBranchExists` does expect only branches so tags and commits are not supported in the current version. Relatedly, it looks like gut does not make an attempt to reconcile a dirty working tree with switch: if it's dirty you either abort the switch or throw away your changes, but it could be helpful to tell the user they could also stash the changes and make the switch when aborting or offer to stash instead of just throwing away the changes.
- julien040 4y agoTo switch to a commit, run "git goto <commit Hash>". However, you cannot switch a tag. I should move this switch command under the branch command. Additionally, it is a good idea to advise to stash changes; I will likely add it in the next release.