fix path to the temp file used to accumulate the patch edits ok stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/lib/patch.c b/lib/patch.c
index 84226a5..672f8da 100644
--- a/lib/patch.c
+++ b/lib/patch.c
@@ -383,7 +383,7 @@ apply_patch(struct got_worktree *worktree, struct got_repository *repo,
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;
@@ -419,8 +419,13 @@ apply_patch(struct got_worktree *worktree, struct got_repository *repo,
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;
@@ -509,6 +514,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)