Commit 14e5d4dcac6e70e8ce1dc7434f4e4f5aa6dbf963

Stefan Sperling 2019-02-05T22:25:42

fix bug with wrong size comparison in get_file_status()

diff --git a/lib/worktree.c b/lib/worktree.c
index 6a1ed92..708cf62 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -999,7 +999,7 @@ get_file_status(unsigned char *status, struct got_fileindex_entry *ie,
 			if (blen != 0)
 				*status = GOT_STATUS_MODIFIY;
 			break;
-		} else if (blen == flen) {
+		} else if (blen - hdrlen == flen) {
 			/* Skip blob object header first time around. */
 			if (memcmp(bbuf + hdrlen, fbuf, flen) != 0) {
 				*status = GOT_STATUS_MODIFIY;
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index d6d36bc..c74933d 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -28,6 +28,7 @@ function test_status_basic {
 	echo "modified alpha" > $testroot/wt/alpha
 	echo "unversioned file" > $testroot/wt/foo
 	rm $testroot/wt/epsilon/zeta
+	touch $testroot/wt/beta
 
 	echo 'M  alpha' > $testroot/stdout.expected
 	echo '!  epsilon/zeta' >> $testroot/stdout.expected