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 13ef94b898..d4056871b0 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 @@ public class FileRepository extends Repository { try { if (snapshot == null) { snapshot = FileSnapshot.save(indexFile); - } else if (snapshot.isModified(indexFile)) { - snapshotLock.unlock(); - notifyIndexChanged(false); + return; } - } finally { - if (snapshotLock.isHeldByCurrentThread()) { - snapshotLock.unlock(); + if (!snapshot.isModified(indexFile)) { + return; } + } finally { + snapshotLock.unlock(); } + notifyIndexChanged(false); } /** {@inheritDoc} */ -- 2.39.5