Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Idempotent" pick #428

Open
bonki opened this issue Mar 15, 2024 · 2 comments
Open

"Idempotent" pick #428

bonki opened this issue Mar 15, 2024 · 2 comments

Comments

@bonki
Copy link

bonki commented Mar 15, 2024

Could we have pick by default not generate a patch if it would result in an empty patch?

E.g.

$ stg pick another-branch
[...]
$ stg pick another-branch
- foo
> foo (empty)

The second operation should imho be a no-op. This would also have the side effect to disallow operations which don't make much sense to begin with, e.g.

$ stg pick HEAD
@bonki bonki changed the title "Idempotent" pick "Idempotent" pick Mar 15, 2024
@jpgrayson
Copy link
Collaborator

I think this idea has merit. Though it is risky to modify a long-standing default behavior.

How would you propose to detect that a pick is a duplicate? I believe the only way would be to play-out the patch application. I.e. we don't know the pick is unnecessary until we've done the pick and the patch ends up empty (i.e. we net the same tree after patch application).

@palves
Copy link

palves commented Apr 19, 2024

(As a long term user just now migrating from stgit 1 to stgit 2, it seems odd to me to break an invariant like stg pick creating a new patch. )

I think that "stg pick" not creating a patch can be dangerous for people with scripts on top of stgit. Suddently something as simple as "stg pick ...; stg pop" can pop the wrong thing.

Also, sometimes even if the commit is empty, the commit log that comes with the empty patch could still be something that you want to pick.

Thus, IMHO if this were changed, it should be a non-default option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants