Commit f179e66de44d3541fbbcf6be9a5bcc70465f0bc9

Stefan Sperling 2020-07-23T14:22:40

use a shortcut in get_file_status() for detecting symlinks appearing on disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/worktree.c b/lib/worktree.c
index 33605c9..1bf520b 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1721,6 +1721,12 @@ get_file_status(unsigned char *status, struct stat *sb,
 	if (!stat_info_differs(ie, sb))
 		goto done;
 
+	if (S_ISLNK(sb->st_mode) &&
+	    got_fileindex_entry_filetype_get(ie) != GOT_FILEIDX_MODE_SYMLINK) {
+		*status = GOT_STATUS_MODIFY;
+		goto done;
+	}
+
 	if (staged_status == GOT_STATUS_MODIFY ||
 	    staged_status == GOT_STATUS_ADD)
 		memcpy(id.sha1, ie->staged_blob_sha1, sizeof(id.sha1));