When I run new-sources during resolving merge conflicts on sources or .gitignore file, the cloned repo is broken and may not be recoverable.
A reproducible example:
Clone a package:
[fedora-scm]$ fedpkg clone lmfit [fedora-scm]$ cd lmfit/
Create a side branch and commit a change in sources or .gitignore:
[lmfit (master)]$ git checkout -b fork [lmfit (fork)]$ cat sources 7483d8311da3f3ec5a772613df0e7c62 lmfit-6.1.tgz [lmfit (fork)]$ nano sources [lmfit (fork *)]$ cat sources xxxxxxxxxxxxxxxxxxxxxxxxx lmfit-6.1.tgz [lmfit (fork *)]$ git commit -am"Edit sources in fork branch"
Go back to original branch and commit a conflicting change:
[lmfit (fork)]$ git checkout master [lmfit (master)]$ cat sources 7483d8311da3f3ec5a772613df0e7c62 lmfit-6.1.tgz [lmfit (master)]$ nano sources [lmfit (master *)]$ cat sources yyyyyyyyyyyyyyyyyyyyyyyy lmfit-6.1.tgz [lmfit (master *)]$ git commit -am"Edit sources in master branch"
Merge the side branch to the original branch. This is a conflict.
[lmfit (master)]$ git merge fork Auto-merging sources CONFLICT (content): Merge conflict in sources Automatic merge failed; fix conflicts and then commit the result. [lmfit (master *+|MERGING)]$ cat sources <<<<<<< HEAD yyyyyyyyyyyyyyyyyyyyyyyy lmfit-6.1.tgz ======= xxxxxxxxxxxxxxxxxxxxxxxxx lmfit-6.1.tgz >>>>>>> fork
Fix the conflict somehow.
[lmfit (master *+|MERGING)]$ nano sources [lmfit (master *+|MERGING)]$ cat sources yyyyyyyyyyyyyyyyyyyyyyyy lmfit-6.1.tgz [lmfit (master *+|MERGING)]$ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: sources no changes added to commit (use "git add" and/or "git commit -a")
Before you git add the file, you decide to run new-sources to have the desired content of sources and .gititngore:
git add
new-sources
[lmfit (master *+|MERGING)]$ touch a [lmfit (master *+%|MERGING)]$ fedpkg new-sources a ... Source upload succeeded. Don't forget to commit the sources file
Fatal, your git repo is broken, you're computer will explode and you will die a horrible dead:
[lmfit (master *+|MERGING)]$ git status fatal: multiple stage entries for merged file 'sources'
This is on Fedora 26. fedpkg-1.28-1.fc26.noarch python2-rpkg-1.49-2.fc26.noarch
In short, new-sources does not do anything special except uploading files to lookaside and write sources files into files sources and .gitignore.
sources
.gitignore
fedpkg inherits new-sources from rpkg, so what rpkg can do, I think, would be to check if repository is dirty before making any changes to repository. If it is, give a message and stop.
@churchyard Do you think this is an acceptable way to avoid that break?
Well it would certainly be better than it's now.
However I don't know how rpkg does it, but when instead of fedpkg new-sources a I do:
fedpkg new-sources a
echo whatnot > sources echo whatnot >> .gitignore git add sources .gitignore
I don't get this situation.
This was filed in bugzilla recently: https://bugzilla.redhat.com/show_bug.cgi?id=1563266
I added a few links to discussion of the issue which prompted the check which results in the 'fatal' error. It seems like this may be a bug in GitPython (or a lower-level dep like gitdb).
I'm going to reassign that bug to rpkg for the moment. It might be further reassigned to GitPython or gitdb, or be closed in favor of this issue. I'm not sure what's best. Having a clear way to reproduce it is handy, so I'm glad I stumbled across this. :)
This issue has been unresolved for more than a year, and is going to be closed within a week if no further action is taken. If you feel this is in error, please contact me. This is a cleaning process suggested by Jay Greguske. Copy of this ticket was already closed in JIRA tracker.
If you feel this is in error, please contact me
I feel this is an error.