Download raw body.
got patch and directories
On Mon, Jul 25, 2022 at 04:51:15PM +0200, Omar Polo wrote:
> the other day i typoed something and fed a directory to `got patch'
> instead of a file; that made got segfault. (in this case it's pledge
> that doesn't allow to send directory fds.)
>
> in theory 'got patch' should work (sometimes) when fed with a fifo:
> got-read-patch needs to do some seeking, but often the buffering of
> FILEs has us covered. i guess it's not that important thought.
Requiring a regular file is perfectly fine. ok stsp
> diff /home/op/w/got
> commit - 10a16316a03005a07c45b2bbf1b5644b64e846fb
> path + /home/op/w/got
> blob - 426fe05030db9048691647f7a8580d916d95ab60
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -7941,6 +7941,7 @@ cmd_patch(int argc, char *argv[])
> const struct got_error *error = NULL, *close_error = NULL;
> struct got_worktree *worktree = NULL;
> struct got_repository *repo = NULL;
> + struct stat sb;
> const char *errstr;
> char *cwd = NULL;
> int ch, nop = 0, strip = -1, reverse = 0;
> @@ -7980,6 +7981,14 @@ cmd_patch(int argc, char *argv[])
> error = got_error_from_errno2("open", argv[0]);
> return error;
> }
> + if (fstat(patchfd, &sb) == -1) {
> + error = got_error_from_errno2("fstat", argv[0]);
> + goto done;
> + }
> + if (!S_ISREG(sb.st_mode)) {
> + error = got_error_path(argv[0], GOT_ERR_BAD_FILETYPE);
> + goto done;
> + }
> } else
> usage_patch();
>
>
>
got patch and directories