diff options
Diffstat (limited to 'org.eclipse.jgit.pgm')
3 files changed, 25 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index 2a5a31eba8..b2ec57c749 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -155,6 +155,8 @@ needSingleRevision=Needed a single revision noGitRepositoryConfigured=No Git repository configured. noNamesFound=No names found, cannot describe anything. noSuchFile=no such file: {0} +noSuchPathInRef=no such path ''{0}'' in {1} +noSuchRef=no such ref: {0} noSuchRemoteRef=no such remote ref: ''{0}'' noSystemConsoleAvailable=No System.console available noTREESectionInIndex=no 'TREE' section in index diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java index e38cb468d9..b67b04c5be 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java @@ -67,6 +67,7 @@ import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectReader; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.pgm.internal.CLIText; @@ -178,14 +179,28 @@ class Blame extends TextBuiltin { } generator.reverse(rangeStart, rangeEnd); } else if (revision != null) { - generator.push(null, db.resolve(revision + "^{commit}")); //$NON-NLS-1$ + ObjectId rev = db.resolve(revision + "^{commit}"); //$NON-NLS-1$ + if (rev == null) { + throw die(MessageFormat.format(CLIText.get().noSuchRef, + revision)); + } + generator.push(null, rev); } else { - generator.push(null, db.resolve(Constants.HEAD)); + ObjectId head = db.resolve(Constants.HEAD); + if (head == null) { + throw die(MessageFormat.format(CLIText.get().noSuchRef, + Constants.HEAD)); + } + generator.push(null, head); if (!db.isBare()) { DirCache dc = db.readDirCache(); int entry = dc.findEntry(file); if (0 <= entry) { generator.push(null, dc.getEntry(entry).getObjectId()); + } else { + throw die(MessageFormat.format( + CLIText.get().noSuchPathInRef, file, + Constants.HEAD)); } File inTree = new File(db.getWorkTree(), file); @@ -196,6 +211,10 @@ class Blame extends TextBuiltin { } blame = BlameResult.create(generator); + if (blame == null) { + throw die(MessageFormat.format(CLIText.get().noSuchPathInRef, + file, revision != null ? revision : Constants.HEAD)); + } begin = 0; end = blame.getResultContents().size(); if (rangeString != null) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java index 7b9401f362..1054944ffd 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java @@ -257,6 +257,8 @@ public class CLIText extends TranslationBundle { /***/ public String noGitRepositoryConfigured; /***/ public String noNamesFound; /***/ public String noSuchFile; + /***/ public String noSuchPathInRef; + /***/ public String noSuchRef; /***/ public String noSuchRemoteRef; /***/ public String noTREESectionInIndex; /***/ public String nonFastForward; |