commit ce3641f681bc648a11a3b5ba3653f1237ec2b1f3 from: Stefan Sperling via: Thomas Adam date: Sun Oct 16 09:34:56 2022 UTC simplify the way 'got patch' opens a tempfile when reading from stdin Also add basic test coverage for reading patches from stdin, while here. ok op@ commit - a4fde4bc1b5aeb691045412b65cd19e4e1b536a3 commit + ce3641f681bc648a11a3b5ba3653f1237ec2b1f3 blob - e402fac19e8422c24e10ed606f227fcbca4cf819 blob + a7caaf369688a4e4479b2fa4d61cefe883d594e7 --- 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_opentempfd"); 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 @@ test_patch_basic() { +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