Merge branch 'stable-2.11' into stable-2.12

* stable-2.11:
  ListTags: Fix NPE when annotated/signed tag has no tagger info

Change-Id: Ie975b01241fdb444b207a2a98a05b26f272173c1
This commit is contained in:
David Pursehouse 2015-12-08 10:25:41 +09:00
commit a02880b61c
2 changed files with 6 additions and 3 deletions

View File

@ -2425,7 +2425,7 @@ points. For annotated tags, the revision of the tag object.
tag points.
|`message`|Only set for annotated tags.|The tag message. For signed tags, includes
the signature.
|`tagger`|Only set for annotated tags.|The tagger as a
|`tagger`|Only set for annotated tags, if present in the tag.|The tagger as a
link:rest-api-changes.html#git-person-info[GitPersonInfo] entity.
|=========================

View File

@ -34,6 +34,7 @@ import com.google.inject.Provider;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevObject;
@ -154,14 +155,16 @@ public class ListTags implements RestReadView<ProjectResource> {
throws MissingObjectException, IOException {
RevObject object = rw.parseAny(ref.getObjectId());
if (object instanceof RevTag) {
RevTag tag = (RevTag)object;
// Annotated or signed tag
RevTag tag = (RevTag)object;
PersonIdent tagger = tag.getTaggerIdent();
return new TagInfo(
ref.getName(),
tag.getName(),
tag.getObject().getName(),
tag.getFullMessage().trim(),
CommonConverters.toGitPerson(tag.getTaggerIdent()));
tagger != null ?
CommonConverters.toGitPerson(tag.getTaggerIdent()) : null);
} else {
// Lightweight tag
return new TagInfo(