From b782518caedc7b20e3d568f78a5a1d2b0aa17424 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 8 Jun 2018 09:42:13 +0200 Subject: [PATCH] Refactor FileRepository.detectIndexChange() Change-Id: I50c751e2e90f685dc27043c569da2eb210d4611b Signed-off-by: Matthias Sohn --- .../jgit/internal/storage/file/FileRepository.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index 13ef94b89..d4056871b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java @@ -557,15 +557,15 @@ private void detectIndexChanges() { try { if (snapshot == null) { snapshot = FileSnapshot.save(indexFile); - } else if (snapshot.isModified(indexFile)) { - snapshotLock.unlock(); - notifyIndexChanged(false); + return; + } + if (!snapshot.isModified(indexFile)) { + return; } } finally { - if (snapshotLock.isHeldByCurrentThread()) { - snapshotLock.unlock(); - } + snapshotLock.unlock(); } + notifyIndexChanged(false); } /** {@inheritDoc} */