Fix getPackedRefs to not throw NoSuchFileException

Since Files.newInputStream is from java.nio package, it throws
java.nio.file.NoSuchFileException. This was missed in the change
I00da88e. Without this change, getPackedRefs fails with
NoSuchFileException when there is no packed-refs file in a project.

Change-Id: I93c202ddb73a0a5979af8e4d09e45f5645664b45
Signed-off-by: Prudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
This commit is contained in:
Prudhvi Akhil Alahari 2023-02-16 16:41:55 +05:30
parent b5de5ccb9e
commit 012cb77930
1 changed files with 2 additions and 1 deletions

View File

@ -35,6 +35,7 @@
import java.io.InterruptedIOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.security.DigestInputStream;
import java.security.MessageDigest;
@ -911,7 +912,7 @@ PackedRefList getPackedRefs() throws IOException {
try (InputStream stream = Files
.newInputStream(packedRefsFile.toPath())) {
// open the file to refresh attributes (on some NFS clients)
} catch (FileNotFoundException e) {
} catch (FileNotFoundException | NoSuchFileException e) {
// Ignore as packed-refs may not exist
}
//$FALL-THROUGH$