Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338839

Summary: Repository.resolve() confused on refs/heads/foo-gbed2
Product: [Technology] JGit Reporter: Shawn Pearce <sop>
Component: JGitAssignee: Shawn Pearce <sop>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 0.11   
Target Milestone: 0.12   
Hardware: All   
OS: All   
Whiteboard:

Description Shawn Pearce CLA 2011-03-03 12:41:17 EST
resolve() tries to parse the input string "refs/heads/foo-gbed2" as though it was the output of git describe. If bed2 isn't a unique object abbreviation in this repository, resolve() crashes. If it is unique, resolve() may be returning incorrect results and return the object that starts with bed2 and *not* the current value of the branch named foo-gbed2.

Gerrit Code Review ran into this because it passed a branch name such as above into RemoteRefUpdate()'s constructor, which only accepts a String and passes its input down into resolve() to convert it to an ObjectId.

Two things should happen with this bug:

- RemoteRefUpdate should support additional constructor patterns to take ObjectId and/or Ref so Gerrit Code Review can be more explicit about its request and avoid the ambiguous parsing that resolve() may be doing.

- resolve() should be more careful about its decision to use the -g `git describe` style variant when parsing. If the input starts with "refs/" it should never use the -g suffix rule. If the -g suffix isn't all hex (e.g. "foo-gbed2-dev") it also shouldn't use the -g suffix rule.
Comment 1 Shawn Pearce CLA 2011-03-03 19:21:33 EST
I have a proposed set of fixes for this, will upload for review in a few minutes.
Comment 2 Shawn Pearce CLA 2011-03-03 19:28:15 EST
Changes posted:

  http://egit.eclipse.org/r/2637
  http://egit.eclipse.org/r/2638