mackyle / topgit

TopGit - A different patch queue manager
https://repo.or.cz/topgit/pro.git
Other
67 stars 7 forks source link

add --no-update option to "tg create" #4

Closed pmolodo closed 7 years ago

pmolodo commented 7 years ago

Useful for converting "normal" branches into "topgit-controlled" branches after-the-fact

I do this all the time with simple one-commit pulls - and then if I need to change it into a topgit-branch after the fact, I use this flag

mackyle commented 7 years ago

So I had this in my TODO list for a while and it ended up with this comment:

Looking at your patch it seems like it does more than just not run "tg update" at the end.

Since "tg update" only ever runs if there's more than one dependency and your suggested use case only has a branch name and a single dependency so "tg update" will never be run in that case anyway. So I'm unclear on why it doesn't already work for your use case out-of-the-box.

Is it that you want --no-update to do this?

git checkout my_bugfix
tg create --no-deps tg/my_bugfix
tg depend add master

But all in one step? I think I'd rather see that written like this though:

git checkout my_bugfix
tg create --no-update tg/my_bugfix HEAD master

(You can't actually use HEAD or "@" as an alias for the branch it's a symref for in the tg create deps list...yet). You can, however, do this:

git checkout my_bugfix
tg create --no-commit tg/my_bugfix my_bugfix master
# the new tg/my_bugfix branch actually exists at this point
# it just has no commits attributed to it
git commit --no-edit # actually commits the .topmsg and .topdeps

So my initial inclination for this one is to re-activate my original --no-update TODO item that does nothing except suppress the final "tg update" in the case of more than one dependency and enhance the logic so the HEAD/@ shortcut (Git allows "@" as a shortcut for "HEAD" that's why tg does too) can be used in the dependency list at "tg create" time as a shortcut for HEAD's symref. That would make your use case into this:

git checkout my_bugfix
tg create --no-update tg/my_bugfix @ master

Although if the "my_bugfix" branch is a descendant of "master" then the "--no-update" option is superfluous as the update will end up not actually doing anything anyway and it doesn't matter if there's a "--no-update" option or not in that case.

So my initial inclination is not to accept this patch in its current form.

A "--no-update" option should do exactly what it sounds like: "not run tg update" rather than changing the semantics of the tg create command when that's not necessary to satisfy the use case.

pmolodo commented 7 years ago

Your suggestion would work for my use case - apologies, I think I probably should have called the option "--no-checkout"... I come from a mercurial background originally, where the "checkout" command is actually called "update". My thing wasn't so much that I wanted to avoid the "tg update", so much as I wanted to avoid the "git checkout" that it does first.

However, your suggested alternative of allowing "@" or "HEAD" as a dependency (which would presumably be special cased to not be added to the actual .topdeps file) would work fine too.

I'm likely not going to bother implementing it, however, so I'm going to go ahead and close this PR. Appreciate you taking the time to read it over, though!