aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-01-09 18:56:45 -0800
committerShawn O. Pearce <spearce@spearce.org>2010-01-23 11:10:56 -0800
commit73b6efc9289d6f7b6c147f4c2e2c62d2134fd7f3 (patch)
treecac4f5481cabdbcb25a16e04df83917b22d462a4 /org.eclipse.jgit.pgm/src
parent01b5392cdbc12ce2e21fd1d1afbd61fdf97e1c38 (diff)
downloadjgit-73b6efc9289d6f7b6c147f4c2e2c62d2134fd7f3.tar.gz
jgit-73b6efc9289d6f7b6c147f4c2e2c62d2134fd7f3.zip
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>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
index 3fe50d6682..571f34b05d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009, Google Inc.
+ * Copyright (C) 2008-2010, Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -164,8 +164,11 @@ class Clone extends AbstractFetchCommand {
private void doCheckout(final Ref branch) throws IOException {
if (branch == null)
throw die("cannot checkout; no HEAD advertised by remote");
- if (!Constants.HEAD.equals(branch.getName()))
- db.writeSymref(Constants.HEAD, branch.getName());
+ if (!Constants.HEAD.equals(branch.getName())) {
+ RefUpdate u = db.updateRef(Constants.HEAD);
+ u.disableRefLog();
+ u.link(branch.getName());
+ }
final Commit commit = db.mapCommit(branch.getObjectId());
final RefUpdate u = db.updateRef(Constants.HEAD);