package org.kohsuke.github;

/**
 * A branch in a repository.
 * 
 * @author Yusuke Kokubo
 */
public class GHBranch {
    private GitHub root;
    private GHRepository owner;

    private String name;
    private Commit commit;

    public static class Commit {
        String sha,url;
    }

    public GitHub getRoot() {
        return root;
    }

    /**
     * Repository that this branch is in.
     */
    public GHRepository getOwner() {
        return owner;
    }

    public String getName() {
        return name;
    }

    /**
     * The commit that this branch currently points to.
     */
    public String getSHA1() {
        return commit.sha;
    }

    @Override
    public String toString() {
        return "Branch:" + name + " in " + owner.getUrl();
    }

    /*package*/ GHBranch wrap(GHRepository repo) {
        this.owner = repo;
        this.root = repo.root;
        return this;
    }
}

@@ -704,24 +704,106 @@
 oString() %7B%0A
+        final String url = owner != null ? owner.getUrl().toString() : %22unknown%22;%0A
         retu
@@ -833,30 +833,19 @@
  in %22 + 
-owner.getUrl()
+url
 ;%0A    %7D%0A

Fix potential NPE in the code