Commit e5f8a8f3 authored by Brian Long's avatar Brian Long
Browse files

added some debug/trace logging

parent 388cdb2d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -69,19 +69,28 @@ public class ExtendedGit extends CachedGit {
	 */
	public Ref normalize(String localBranchName, String exactRemoteBranchName)
	throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException, GitAPIException, IOException {
		if (this.logger.isTraceEnabled())
			this.logger.trace("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "')");
		
		Ref localRef = this.getRepository().exactRef(Constants.R_HEADS + localBranchName);
		if (localRef == null) {
			if (this.logger.isDebugEnabled())
				this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): local branch does not yet exist");
			localRef = this.branchCreate()
					.setUpstreamMode(SetupUpstreamMode.NOTRACK)
					.setName(localBranchName)
					.setStartPoint(exactRemoteBranchName)
					.call();
			if (this.logger.isDebugEnabled())
				this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): created local branch: " + localRef.getName());
		}
		
		Ref checkoutRef = this.checkout()
				.setName(localBranchName)
				.setStartPoint(exactRemoteBranchName)
				.call();
		if (this.logger.isDebugEnabled())
			this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): checked out");
		
		if (!localRef.getObjectId().getName().equals(checkoutRef.getObjectId().getName())) {
			this.logger.warn("A checkout did not move the local branch to the proper commit; performing reset: " + localRef.getName());
@@ -89,6 +98,8 @@ public class ExtendedGit extends CachedGit {
					.setMode(ResetType.HARD)
					.setRef(exactRemoteBranchName)
					.call();
			if (this.logger.isDebugEnabled())
				this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): reset");
		}
		
		return checkoutRef;