Replace writeSymref with RefUpdate.link
commit73b6efc9289d6f7b6c147f4c2e2c62d2134fd7f3
authorShawn O. Pearce <spearce@spearce.org>
Sun, 10 Jan 2010 02:56:45 +0000 (9 18:56 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 23 Jan 2010 19:10:56 +0000 (23 11:10 -0800)
treecac4f5481cabdbcb25a16e04df83917b22d462a4
parent01b5392cdbc12ce2e21fd1d1afbd61fdf97e1c38
Replace writeSymref with RefUpdate.link

By using RefUpdate for symbolic reference creation we can reuse
the logic related to updating the reflog with the event, without
needing to expose something such as the legacy ReflogWriter class
(which we no longer have).

Applications using writeSymref must update their code to use the
new pattern of changing the reference through the updateRef method:

    String refName = "refs/heads/master";
    RefUpdate u = repository.updateRef(Constants.HEAD);
    u.setRefLogMessage("checkout: moving to " + refName, false);
    switch (u.link(refName)) {
    case NEW:
    case FORCED:
    case NO_CHANGE:
        // A successful update of the reference
        break;
    default:
        // Handle the failure, e.g. for older behavior
        throw new IOException(u.getResult());
    }

Change-Id: I1093e1ec2970147978a786cfdd0a75d0aebf8010
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefUpdateTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectoryRename.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectoryUpdate.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java