commit 94af5a06f725ffeb02b8a53eb2010a094d0a8d14 from: Omar Polo via: Thomas Adam date: Tue Mar 08 20:30:04 2022 UTC fix path to the temp file used to accumulate the patch edits ok stsp commit - 10cdd9aa9fb3ff6b9725b1aa5d44e1fb8f791e18 commit + 94af5a06f725ffeb02b8a53eb2010a094d0a8d14 blob - af4423820093c59ffc872ceda9571a41e456f853 blob + f85a91adb23d2606865334bb163b48fcea0ad221 --- lib/patch.c +++ lib/patch.c @@ -382,7 +382,7 @@ apply_patch(struct got_worktree *worktree, struct got_ const struct got_error *err = NULL; struct got_pathlist_head paths; struct got_pathlist_entry *pe; - char *path = NULL, *tmppath = NULL; + char *path = NULL, *tmppath = NULL, *template = NULL; FILE *orig = NULL, *tmp = NULL; struct got_patch_hunk *h; size_t i; @@ -418,8 +418,13 @@ apply_patch(struct got_worktree *worktree, struct got_ goto done; } - err = got_opentemp_named(&tmppath, &tmp, - got_worktree_get_root_path(worktree)); + if (asprintf(&template, "%s/got-patch", + got_worktree_get_root_path(worktree)) == -1) { + err = got_error_from_errno(template); + goto done; + } + + err = got_opentemp_named(&tmppath, &tmp, template); if (err) goto done; @@ -508,6 +513,7 @@ rename: else printf("M %s\n", path); /* XXX */ done: + free(template); if (err != NULL && p->old == NULL && path != NULL) unlink(path); if (tmp != NULL)