commit - 6d9d28c32eec189b3f26c36f5510c7c4513c8ffd
commit + 73a5ef678f0ee5f125fa5154baffb9cde3a1b133
blob - 5b44fb5c530b1eb6b406a95d0f5330136258c98d
blob + 3a8dd15749445c01ce379f9b5bae078a58365c39
--- lib/worktree.c
+++ lib/worktree.c
goto done;
}
- fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW,
+ fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
GOT_DEFAULT_FILE_MODE);
if (fd == -1) {
err = got_error_from_errno();
goto done;
}
- fd = open(path, O_RDONLY | O_EXCL | O_EXLOCK | O_NOFOLLOW);
+ fd = open(path, O_RDONLY | O_EXLOCK | O_NONBLOCK | O_NOFOLLOW);
if (fd == -1) {
- err = got_error_from_errno();
+ err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
+ : got_error_from_errno());
goto done;
}
goto done;
}
- fd = open(path_fileindex, O_RDWR | O_EXCL | O_EXLOCK | O_NOFOLLOW,
+ fd = open(path_fileindex, O_RDWR | O_EXLOCK | O_NONBLOCK | O_NOFOLLOW,
GOT_DEFAULT_FILE_MODE);
if (fd == -1) {
- err = got_error(GOT_ERR_WORKTREE_BUSY);
+ err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
+ : got_error_from_errno());
goto done;
}