This happened recently and I have not tried to reproduce it but thought it would be good to note it here.
I had a patch in the current branch called "diff". I also had a patch file called /tmp/diff. Without thinking, I used "stg import /tmp/diff" to pull that patch file into the current branch.
The result was two patches in the same branch called "diff". Subsequently, normal stg operations resulted in a Python exception.
To recover, I edited the branch's unapplied file and removed the second "diff".
To prevent stgit metadata corruption from happening, "stg import" could:
- Fail to import the patch file
- Select a distinct name for the imported patch (eg, "diff2")
- Create a new branch and use the expected patch name