Download raw body.
minor 'got patch' simplification
Simplify the way 'got patch' opens a tempfile when reading from stdin. Also add basic test coverage for reading patches from stdin, while here. Noticed while looking for calls to unlink() which lack any error checking. diff d2533287ff253bfb6fe08ddc0005ac3349fdf38c 557647147e5a1df9302c01776f6ee9a99815e3b5 commit - d2533287ff253bfb6fe08ddc0005ac3349fdf38c commit + 557647147e5a1df9302c01776f6ee9a99815e3b5 blob - ef5a8b59c5e55dfdeec6f464375604437cc707d8 blob + 913aa0d9c49c4d45eb2e7eaef91e7df770fd734a --- got/got.c +++ got/got.c @@ -7862,15 +7862,12 @@ patch_from_stdin(int *patchfd) { const struct got_error *err = NULL; ssize_t r; - char *path, buf[BUFSIZ]; + char buf[BUFSIZ]; sig_t sighup, sigint, sigquit; - err = got_opentemp_named_fd(&path, patchfd, - GOT_TMPDIR_STR "/got-patch"); - if (err) - return err; - unlink(path); - free(path); + *patchfd = got_opentempfd(); + if (*patchfd == -1) + return got_error_from_errno("got_opentemp_fd"); sighup = signal(SIGHUP, SIG_DFL); sigint = signal(SIGINT, SIG_DFL); blob - 1bcdb584a653439ff381dc63d0dc88145ee8fa36 blob + f8f949b792887413b26e30cab123e9e1c57ae123 --- regress/cmdline/patch.sh +++ regress/cmdline/patch.sh @@ -87,7 +87,7 @@ EOF +103 EOF - (cd $testroot/wt && got patch patch) > $testroot/stdout + (cd $testroot/wt && got patch < patch) > $testroot/stdout if [ $ret -ne 0 ]; then test_done "$testroot" $ret return 1
minor 'got patch' simplification