Bug 486043 - Ref conflict error message is lacking compared to CGit
Summary: Ref conflict error message is lacking compared to CGit
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 4.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-18 09:51 EST by Christopher Mackey CLA
Modified: 2016-01-18 09:51 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Mackey CLA 2016-01-18 09:51:58 EST
The error returned by JGit when trying to push a ref that conflicts with an existing ref does not provide the level of detail CGit provides. For example:

1. Create and push branch refs/heads/prefix/suffix
2. Create and try to push branch refs/heads/prefix

CGit will return the following error:

[chris@antergos test-ref]$ git push origin prefix 
Total 0 (delta 0), reused 0 (delta 0)
remote: error: cannot lock ref 'refs/heads/prefix': 'refs/heads/prefix/suffix' exists; cannot create 'refs/heads/prefix'
To /home/chris/tmp/test-ref.git/
 ! [remote rejected] prefix -> prefix (failed to update ref)
error: failed to push some refs to '/home/chris/tmp/test-ref.git/'

But services using JGit return the following:

GitBlit:

[chris@antergos gitblit]$ git push origin prefix 
Total 0 (delta 0), reused 0 (delta 0)
remote: Updating references: 100% (1/1)
To https://chris@gitblit-server/r/testing/test-prefix.git
 ! [remote rejected] prefix -> prefix (failed to lock)
error: failed to push some refs to 'https://chris@gitblit-server/r/testing/test-prefix.git'

Gerrit:

[chris@antergos gerrit]$ git push origin prefix 
Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done    
To http://admin@localhost:8080/gerrit
 ! [remote rejected] prefix -> prefix (failed to lock)
error: failed to push some refs to 'http://admin@localhost:8080/gerrit'

I'm not sure if this is actually the responsibility of GitBlit/Gerrit to do. JGit however seems to be throwing back a LOCK_FAILURE result, which can be misleading given that that kind of error is often transient, but this particular case is not.