Bug 1188913

Summary: [abrt] git-review: cmd.py:152:run_command_exc:DeleteBranchFailed: Failed to delete branch
Product: [Fedora] Fedora Reporter: Jeff Morriss <jeff.morriss>
Component: git-reviewAssignee: Pete Zaitcev <zaitcev>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: jeff.morriss, zaitcev
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://retrace.fedoraproject.org/faf/reports/bthash/17215286789f8b03264a50668bb299c36b92d981
Whiteboard: abrt_hash:ecd6b73e228b37f7709bcc2b0ce7d08ce1c0bdc8
Fixed In Version: git-review-1.24-4.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-19 18:00:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
File: backtrace
none
File: environ
none
Possible fix none

Description Jeff Morriss 2015-02-04 02:17:58 UTC
Description of problem:
0) (Forget to checkout a branch for your change.  So you're still working on master.)
1) git commit file.c
2) git review -f  << gets a Python backtrace:

Switched to branch 'master'
Traceback (most recent call last):
  File "/usr/bin/git-review", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 1249, in main
    finish_branch(branch)
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 1027, in finish_branch
    "git", "branch", "-D", local_branch)
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 152, in run_command_exc
    raise klazz(rc, output, argv, env)
git_review.cmd.DeleteBranchFailed: Failed to delete branch
The following command failed with exit code 1
    "git branch -D master"
-----------------------
error: Cannot delete the branch 'master' which you are currently on.
-----------------------

Version-Release number of selected component:
git-review-1.24-3.fc21

Additional info:
reporter:       libreport-2.3.0
cmdline:        /usr/bin/python /usr/bin/git-review -f
executable:     /usr/bin/git-review
kernel:         3.17.8-300.fc21.x86_64
runlevel:       N 5
type:           Python
uid:            500

Truncated backtrace:
cmd.py:152:run_command_exc:DeleteBranchFailed: Failed to delete branch
The following command failed with exit code 1
    "git branch -D master"
-----------------------
error: Cannot delete the branch 'master' which you are currently on.
-----------------------

Traceback (most recent call last):
  File "/usr/bin/git-review", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 1249, in main
    finish_branch(branch)
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 1027, in finish_branch
    "git", "branch", "-D", local_branch)
  File "/usr/lib/python2.7/site-packages/git_review/cmd.py", line 152, in run_command_exc
    raise klazz(rc, output, argv, env)
DeleteBranchFailed: Failed to delete branch
The following command failed with exit code 1
    "git branch -D master"
-----------------------
error: Cannot delete the branch 'master' which you are currently on.
-----------------------

Local variables in innermost frame:
output: u"error: Cannot delete the branch 'master' which you are currently on."
klazz: <class 'git_review.cmd.DeleteBranchFailed'>
argv: ('git', 'branch', '-D', u'master')
env: {}
rc: 1

Comment 1 Jeff Morriss 2015-02-04 02:18:00 UTC
Created attachment 987900 [details]
File: backtrace

Comment 2 Jeff Morriss 2015-02-04 02:18:01 UTC
Created attachment 987901 [details]
File: environ

Comment 3 Pete Zaitcev 2015-02-04 04:24:34 UTC
Jeff, what's the desired behavior in such case?

Comment 4 Jeff Morriss 2015-02-04 13:57:38 UTC
(In reply to Pete Zaitcev from comment #3)
> Jeff, what's the desired behavior in such case?

Well, I guess an error without the backtrace (and without triggering abortd or whatever it's called)?

Comment 5 Pete Zaitcev 2015-02-04 22:51:15 UTC
Understood, thanks

Comment 6 Pete Zaitcev 2015-02-05 21:13:26 UTC
Created attachment 988612 [details]
Possible fix

Comment 7 Pete Zaitcev 2015-02-05 21:25:22 UTC
Jeff, please test this on your case:
 http://people.redhat.com/zaitcev/tmp/git-review-1.24-3.1.fc21.noarch.rpm

When it blows up, please capture and paste the whole output, in case.

Comment 8 Jeff Morriss 2015-02-06 02:34:11 UTC
Works like a charm, thanks!

~~~
remote: Resolving deltas: 100% (3/3)           
remote: Processing changes: new: 1, refs: 1, done            
remote: 
remote: New Changes:        
remote:   https://code.wireshark.org/review/6977        
remote: 
To ssh://code.wireshark.org:29418/wireshark
 * [new branch]      HEAD -> refs/publish/master
Switched to branch 'master'
Failed to delete branch
The following command failed with exit code 1
    "git branch -D master"
-----------------------
error: Cannot delete the branch 'master' which you are currently on.
-----------------------
~~~

Comment 9 Jeff Morriss 2015-02-06 02:43:22 UTC
Of course this does leave you in the position where things have diverged:

~~~
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)
~~~

(So it's necessary to "get reset HEAD^")

I wonder if git-review could/should warn you that you're on master before proceeding?  Hmm, well, no, I guess that's too late; really git-commit should probably the one to warn you--or maybe even prevent you--from shooting yourself in the foot.

Meh, whatever, most of my git experiences so far have been in finding new and exciting ways to shoot yourself in the foot; this one's not that bad in the end!

Comment 10 Jeff Morriss 2015-02-06 02:45:11 UTC
Hey, I thought I selected "I am providing the requested information" before...  One more try since it doesn't appear to have cleared.

Comment 11 Fedora Update System 2015-02-06 04:01:37 UTC
git-review-1.24-4.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/git-review-1.24-4.fc21

Comment 12 Fedora Update System 2015-02-07 03:57:51 UTC
Package git-review-1.24-4.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing git-review-1.24-4.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-1794/git-review-1.24-4.fc21
then log in and leave karma (feedback).

Comment 13 Pete Zaitcev 2015-02-18 19:17:11 UTC
Since Jeff confirmed the test build in comment #9, I'm pushing to stable.
Hopefuly there's no typo :-)

Comment 14 Fedora Update System 2015-02-19 18:00:04 UTC
git-review-1.24-4.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.