stgit icon indicating copy to clipboard operation
stgit copied to clipboard

"Idempotent" `pick`

Open bonki opened this issue 1 year ago • 2 comments

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 avatar Mar 15 '24 13:03 bonki

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).

jpgrayson avatar Mar 25 '24 13:03 jpgrayson

(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.

palves avatar Apr 19 '24 21:04 palves