Skip to contentSkip to conversation

move the 'empty-line' check in RefDatabase#readLine down a bit to after we removed all the whitespaces.

PATCH New Mark Struberg 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move the 'empty-line' check in RefDatabase#readLine down a bit to after we removed all the whitespaces.

This way we consistently return null regardless if the line is empty or if it does only contain whitespaces.

---
 .../src/org/spearce/jgit/lib/RefDatabase.java      |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java +4 -3
index 477dc62..acc835b 100644
@@ -498,14 +498,15 @@ private static String readLine(final File file)
             throws FileNotFoundException, IOException {
         final byte[] buf = NB.readFully(file, 4096);
         int n = buf.length;
-        if (n == 0)
-            return null;
         
         // remove trailing whitespaces
         while (n > 0 && Character.isWhitespace(buf[n - 1])) {
             n--;
         }
-        
+
+        if (n == 0)
+            return null;
+
         return RawParseUtils.decode(buf, 0, n);
     }
 
Signature · 1 line
1.6.2.5