Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338839 - Repository.resolve() confused on refs/heads/foo-gbed2
Summary: Repository.resolve() confused on refs/heads/foo-gbed2
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 0.11   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 0.12   Edit
Assignee: Shawn Pearce CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-03 12:41 EST by Shawn Pearce CLA
Modified: 2011-03-03 19:28 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 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