From e5f8a8f3a1be7ebd6f3cdbfafad40d66b73676a2 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Thu, 10 Dec 2020 15:21:58 -0500 Subject: [PATCH] added some debug/trace logging --- src/main/java/me/brianlong/git/ExtendedGit.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/me/brianlong/git/ExtendedGit.java b/src/main/java/me/brianlong/git/ExtendedGit.java index e74f672..f9896ab 100644 --- a/src/main/java/me/brianlong/git/ExtendedGit.java +++ b/src/main/java/me/brianlong/git/ExtendedGit.java @@ -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;