diff options
author | Kevin Sawicki | 2012-01-14 23:34:18 +0000 |
---|---|---|
committer | Kevin Sawicki | 2012-01-14 23:34:18 +0000 |
commit | c963e7aacf4d8eaed0081ad31a29344a3cd9cd5a (patch) | |
tree | a0a215f581f215d3f49cff75457126838bacbb80 /org.eclipse.jgit | |
parent | d5c890e0fdbfdd5d532121a2eb812ee2143c8ab5 (diff) | |
download | jgit-c963e7aacf4d8eaed0081ad31a29344a3cd9cd5a.tar.gz jgit-c963e7aacf4d8eaed0081ad31a29344a3cd9cd5a.tar.xz jgit-c963e7aacf4d8eaed0081ad31a29344a3cd9cd5a.zip |
Resolve ~ with no trailing number as the first parent commit
This would previously throw a RevisionSyntaxException
Change-Id: I42b4988c7f6c6454e2ebda13914260e25ac1a889
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 1b649bba52..cf74df638b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -496,14 +496,17 @@ public abstract class Repository { if (!Character.isDigit(rev[l])) break; } - String distnum = new String(rev, i + 1, l - i - 1); int dist; - try { - dist = Integer.parseInt(distnum); - } catch (NumberFormatException e) { - throw new RevisionSyntaxException( - JGitText.get().invalidAncestryLength, revstr); - } + if (l - i > 1) { + String distnum = new String(rev, i + 1, l - i - 1); + try { + dist = Integer.parseInt(distnum); + } catch (NumberFormatException e) { + throw new RevisionSyntaxException( + JGitText.get().invalidAncestryLength, revstr); + } + } else + dist = 1; while (dist > 0) { RevCommit commit = (RevCommit) ref; if (commit.getParentCount() == 0) { |