Commit 3f148bc66e13559704e12d07a8c05612be797de2

Stefan Sperling 2019-07-27T15:59:48

ensure that st_mode keeps being initialized by get_file_status()

diff --git a/lib/worktree.c b/lib/worktree.c
index 2acdc3d..fd98027 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1033,6 +1033,7 @@ stat_info_differs(struct got_fileindex_entry *ie, struct stat *sb)
 	    ie->size == (sb->st_size & 0xffffffff));
 }
 
+/* Report file status and initialize sb->st_mode. */
 static const struct got_error *
 get_file_status(unsigned char *status, struct stat *sb,
     struct got_fileindex_entry *ie, const char *abspath,
@@ -1067,8 +1068,10 @@ get_file_status(unsigned char *status, struct stat *sb,
 		return got_error_from_errno2("open", abspath);
 	}
 
-	if (ie == NULL)
+	if (ie == NULL) {
+		sb->st_mode = GOT_DEFAULT_FILE_MODE;
 		goto done;
+	}
 
 	if (fstat(fd, sb) == -1) {
 		err = got_error_from_errno2("fstat", abspath);