Commit Diff


commit - e0870e443a8dfb50091e64747658a3e0740f82bb
commit + 638f9024045bbe2420143f8868dcc484c231c634
blob - 8c9793810718d7086090d59a084fe0d09f7c2d28
blob + 1b3478d6fcd84eda39aed0a1c511c6d4f9a58084
--- got/got.c
+++ got/got.c
@@ -209,7 +209,7 @@ get_editor(char **editorp)
 
 	*editorp = realpath(editor, NULL);
 	if (*editorp == NULL)
-		return got_error_prefix_errno("relpath");
+		return got_error_from_errno("relpath");
 
 	return NULL;
 }
@@ -253,20 +253,20 @@ apply_unveil(const char *repo_path, int repo_read_only
 	}
 
 	if (repo_path && unveil(repo_path, repo_read_only ? "r" : "rwc") != 0)
-		return got_error_prefix_errno2("unveil", repo_path);
+		return got_error_from_errno2("unveil", repo_path);
 
 	if (worktree_path && unveil(worktree_path, "rwc") != 0)
-		return got_error_prefix_errno2("unveil", worktree_path);
+		return got_error_from_errno2("unveil", worktree_path);
 
 	if (unveil("/tmp", "rwc") != 0)
-		return got_error_prefix_errno2("unveil", "/tmp");
+		return got_error_from_errno2("unveil", "/tmp");
 
 	error = got_privsep_unveil_exec_helpers();
 	if (error != NULL)
 		return error;
 
 	if (unveil(NULL, NULL) != 0)
-		return got_error_prefix_errno("unveil");
+		return got_error_from_errno("unveil");
 
 	return NULL;
 }
@@ -359,7 +359,7 @@ cmd_checkout(int argc, char *argv[])
 		case 'c':
 			commit_id_str = strdup(optarg);
 			if (commit_id_str == NULL)
-				return got_error_prefix_errno("strdup");
+				return got_error_from_errno("strdup");
 			break;
 		case 'p':
 			path_prefix = optarg;
@@ -382,23 +382,23 @@ cmd_checkout(int argc, char *argv[])
 		char *cwd, *base, *dotgit;
 		repo_path = realpath(argv[0], NULL);
 		if (repo_path == NULL)
-			return got_error_prefix_errno2("realpath", argv[0]);
+			return got_error_from_errno2("realpath", argv[0]);
 		cwd = getcwd(NULL, 0);
 		if (cwd == NULL) {
-			error = got_error_prefix_errno("getcwd");
+			error = got_error_from_errno("getcwd");
 			goto done;
 		}
 		if (path_prefix[0]) {
 			base = basename(path_prefix);
 			if (base == NULL) {
-				error = got_error_prefix_errno2("basename",
+				error = got_error_from_errno2("basename",
 				    path_prefix);
 				goto done;
 			}
 		} else {
 			base = basename(repo_path);
 			if (base == NULL) {
-				error = got_error_prefix_errno2("basename",
+				error = got_error_from_errno2("basename",
 				    repo_path);
 				goto done;
 			}
@@ -407,7 +407,7 @@ cmd_checkout(int argc, char *argv[])
 		if (dotgit)
 			*dotgit = '\0';
 		if (asprintf(&worktree_path, "%s/%s", cwd, base) == -1) {
-			error = got_error_prefix_errno("asprintf");
+			error = got_error_from_errno("asprintf");
 			free(cwd);
 			goto done;
 		}
@@ -415,12 +415,12 @@ cmd_checkout(int argc, char *argv[])
 	} else if (argc == 2) {
 		repo_path = realpath(argv[0], NULL);
 		if (repo_path == NULL) {
-			error = got_error_prefix_errno2("realpath", argv[0]);
+			error = got_error_from_errno2("realpath", argv[0]);
 			goto done;
 		}
 		worktree_path = realpath(argv[1], NULL);
 		if (worktree_path == NULL) {
-			error = got_error_prefix_errno2("realpath", argv[1]);
+			error = got_error_from_errno2("realpath", argv[1]);
 			goto done;
 		}
 	} else
@@ -528,7 +528,7 @@ cmd_update(int argc, char *argv[])
 		case 'c':
 			commit_id_str = strdup(optarg);
 			if (commit_id_str == NULL)
-				return got_error_prefix_errno("strdup");
+				return got_error_from_errno("strdup");
 			break;
 		default:
 			usage_update();
@@ -546,7 +546,7 @@ cmd_update(int argc, char *argv[])
 #endif
 	worktree_path = getcwd(NULL, 0);
 	if (worktree_path == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, worktree_path);
@@ -556,7 +556,7 @@ cmd_update(int argc, char *argv[])
 	if (argc == 0) {
 		path = strdup("");
 		if (path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else if (argc == 1) {
@@ -712,7 +712,7 @@ print_commit(struct got_commit_object *commit, struct 
 		s = refs_str;
 		if (asprintf(&refs_str, "%s%s%s", s ? s : "", s ? ", " : "",
 		    name) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			free(s);
 			break;
 		}
@@ -753,7 +753,7 @@ print_commit(struct got_commit_object *commit, struct 
 
 	logmsg0 = strdup(got_object_commit_get_logmsg(commit));
 	if (logmsg0 == NULL)
-		return got_error_prefix_errno("strdup");
+		return got_error_from_errno("strdup");
 
 	logmsg = logmsg0;
 	do {
@@ -770,7 +770,7 @@ print_commit(struct got_commit_object *commit, struct 
 	}
 
 	if (fflush(stdout) != 0 && err == NULL)
-		err = got_error_prefix_errno("fflush");
+		err = got_error_from_errno("fflush");
 	return err;
 }
 
@@ -898,7 +898,7 @@ cmd_log(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 
@@ -910,7 +910,7 @@ cmd_log(int argc, char *argv[])
 	if (argc == 0) {
 		path = strdup("");
 		if (path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else if (argc == 1) {
@@ -922,7 +922,7 @@ cmd_log(int argc, char *argv[])
 		} else {
 			path = strdup(argv[0]);
 			if (path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -934,7 +934,7 @@ cmd_log(int argc, char *argv[])
 		    strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
 	}
 	if (repo_path == NULL) {
-		error = got_error_prefix_errno("strdup");
+		error = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -984,7 +984,7 @@ cmd_log(int argc, char *argv[])
 				id = got_object_id_dup(
 				    got_object_tag_get_object_id(tag));
 				if (id == NULL)
-					error = got_error_prefix_errno(
+					error = got_error_from_errno(
 					    "got_object_id_dup");
 				got_object_tag_close(tag);
 				if (error)
@@ -1085,17 +1085,17 @@ print_diff(void *arg, unsigned char status, const char
 	if (status != GOT_STATUS_DELETE) {
 		if (asprintf(&abspath, "%s/%s",
 		    got_worktree_get_root_path(a->worktree), path) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 
 		f2 = fopen(abspath, "r");
 		if (f2 == NULL) {
-			err = got_error_prefix_errno2("fopen", abspath);
+			err = got_error_from_errno2("fopen", abspath);
 			goto done;
 		}
 		if (lstat(abspath, &sb) == -1) {
-			err = got_error_prefix_errno2("lstat", abspath);
+			err = got_error_from_errno2("lstat", abspath);
 			goto done;
 		}
 	} else
@@ -1107,7 +1107,7 @@ done:
 	if (blob1)
 		got_object_blob_close(blob1);
 	if (f2 && fclose(f2) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	free(abspath);
 	return err;
 }
@@ -1156,7 +1156,7 @@ cmd_diff(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, cwd);
@@ -1172,7 +1172,7 @@ cmd_diff(int argc, char *argv[])
 			    "-r option can't be used when diffing a work tree");
 		repo_path = strdup(got_worktree_get_repo_path(worktree));
 		if (repo_path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 		if (argc == 1) {
@@ -1183,7 +1183,7 @@ cmd_diff(int argc, char *argv[])
 		} else {
 			path = strdup("");
 			if (path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -1196,7 +1196,7 @@ cmd_diff(int argc, char *argv[])
 	if (repo_path == NULL) {
 		repo_path = getcwd(NULL, 0);
 		if (repo_path == NULL)
-			return got_error_prefix_errno("getcwd");
+			return got_error_from_errno("getcwd");
 	}
 
 	error = got_repo_open(&repo, repo_path);
@@ -1336,7 +1336,7 @@ cmd_blame(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	if (repo_path == NULL) {
@@ -1349,13 +1349,13 @@ cmd_blame(int argc, char *argv[])
 			repo_path =
 			    strdup(got_worktree_get_repo_path(worktree));
 			if (repo_path == NULL)
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 			if (error)
 				goto done;
 		} else {
 			repo_path = strdup(cwd);
 			if (repo_path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -1377,7 +1377,7 @@ cmd_blame(int argc, char *argv[])
 		    prefix, (strcmp(prefix, "/") != 0) ? "/" : "",
 		    worktree_subdir, worktree_subdir[0] ? "/" : "",
 		    path) == -1) {
-			error = got_error_prefix_errno("asprintf");
+			error = got_error_from_errno("asprintf");
 			goto done;
 		}
 		error = got_repo_map_path(&in_repo_path, repo, p, 0);
@@ -1477,7 +1477,7 @@ print_tree(const char *path, struct got_object_id *com
 			if (err)
 				goto done;
 			if (asprintf(&id, "%s ", id_str) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				free(id_str);
 				goto done;
 			}
@@ -1491,7 +1491,7 @@ print_tree(const char *path, struct got_object_id *com
 			if (asprintf(&child_path, "%s%s%s", path,
 			    path[0] == '/' && path[1] == '\0' ? "" : "/",
 			    te->name) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				goto done;
 			}
 			err = print_tree(child_path, commit_id, show_ids, 1,
@@ -1564,7 +1564,7 @@ cmd_tree(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	if (repo_path == NULL) {
@@ -1577,13 +1577,13 @@ cmd_tree(int argc, char *argv[])
 			repo_path =
 			    strdup(got_worktree_get_repo_path(worktree));
 			if (repo_path == NULL)
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 			if (error)
 				goto done;
 		} else {
 			repo_path = strdup(cwd);
 			if (repo_path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -1604,7 +1604,7 @@ cmd_tree(int argc, char *argv[])
 			if (asprintf(&p, "%s/%s",
 			    got_worktree_get_path_prefix(worktree),
 			    worktree_subdir) == -1) {
-				error = got_error_prefix_errno("asprintf");
+				error = got_error_from_errno("asprintf");
 				goto done;
 			}
 			error = got_repo_map_path(&in_repo_path, repo, p, 1);
@@ -1696,7 +1696,7 @@ cmd_status(int argc, char *argv[])
 #endif
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 
@@ -1707,7 +1707,7 @@ cmd_status(int argc, char *argv[])
 	if (argc == 0) {
 		path = strdup("");
 		if (path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else if (argc == 1) {
@@ -1759,7 +1759,7 @@ list_refs(struct got_repository *repo)
 		char *refstr;
 		refstr = got_ref_to_str(re->ref);
 		if (refstr == NULL)
-			return got_error_prefix_errno("got_ref_to_str");
+			return got_error_from_errno("got_ref_to_str");
 		printf("%s: %s\n", got_ref_get_name(re->ref), refstr);
 		free(refstr);
 	}
@@ -1862,7 +1862,7 @@ cmd_ref(int argc, char *argv[])
 #endif
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 
@@ -1876,13 +1876,13 @@ cmd_ref(int argc, char *argv[])
 			repo_path =
 			    strdup(got_worktree_get_repo_path(worktree));
 			if (repo_path == NULL)
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 			if (error)
 				goto done;
 		} else {
 			repo_path = strdup(cwd);
 			if (repo_path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -1951,7 +1951,7 @@ cmd_add(int argc, char *argv[])
 	for (x = 0; x < argc; x++) {
 		char *path = realpath(argv[x], NULL);
 		if (path == NULL) {
-			error = got_error_prefix_errno2("realpath", argv[x]);
+			error = got_error_from_errno2("realpath", argv[x]);
 			goto done;
 		}
 		free(path);
@@ -1959,7 +1959,7 @@ cmd_add(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 
@@ -1979,7 +1979,7 @@ cmd_add(int argc, char *argv[])
 	for (x = 0; x < argc; x++) {
 		char *path = realpath(argv[x], NULL);
 		if (path == NULL) {
-			error = got_error_prefix_errno2("realpath", argv[x]);
+			error = got_error_from_errno2("realpath", argv[x]);
 			goto done;
 		}
 
@@ -2039,14 +2039,14 @@ cmd_rm(int argc, char *argv[])
 
 	path = realpath(argv[0], NULL);
 	if (path == NULL) {
-		error = got_error_prefix_errno2("realpath", argv[0]);
+		error = got_error_from_errno2("realpath", argv[0]);
 		goto done;
 	}
 	got_path_strip_trailing_slashes(path);
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, cwd);
@@ -2116,14 +2116,14 @@ cmd_revert(int argc, char *argv[])
 
 	path = realpath(argv[0], NULL);
 	if (path == NULL) {
-		error = got_error_prefix_errno2("realpath", argv[0]);
+		error = got_error_from_errno2("realpath", argv[0]);
 		goto done;
 	}
 	got_path_strip_trailing_slashes(path);
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, cwd);
@@ -2224,13 +2224,13 @@ collect_commit_logmsg(struct got_pathlist_head *commit
 		len = strlen(a->cmdline_log) + 1;
 		*logmsg = malloc(len + 1);
 		if (*logmsg == NULL)
-			return got_error_prefix_errno("malloc");
+			return got_error_from_errno("malloc");
 		strlcpy(*logmsg, a->cmdline_log, len);
 		return NULL;
 	}
 
 	if (asprintf(&template, "%s/logmsg", a->worktree_path) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = got_opentemp_named_fd(&a->logmsg_path, &fd, template);
 	if (err)
@@ -2245,17 +2245,17 @@ collect_commit_logmsg(struct got_pathlist_head *commit
 	close(fd);
 
 	if (stat(a->logmsg_path, &st) == -1) {
-		err = got_error_prefix_errno2("stat", a->logmsg_path);
+		err = got_error_from_errno2("stat", a->logmsg_path);
 		goto done;
 	}
 
 	if (spawn_editor(a->editor, a->logmsg_path) == -1) {
-		err = got_error_prefix_errno("failed spawning editor");
+		err = got_error_from_errno("failed spawning editor");
 		goto done;
 	}
 
 	if (stat(a->logmsg_path, &st2) == -1) {
-		err = got_error_prefix_errno("stat");
+		err = got_error_from_errno("stat");
 		goto done;
 	}
 
@@ -2271,7 +2271,7 @@ collect_commit_logmsg(struct got_pathlist_head *commit
 	/* remove comments */
 	*logmsg = malloc(st2.st_size + 1);
 	if (*logmsg == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		goto done;
 	}
 	len = 0;
@@ -2335,7 +2335,7 @@ cmd_commit(int argc, char *argv[])
 	if (argc == 1) {
 		path = realpath(argv[0], NULL);
 		if (path == NULL) {
-			error = got_error_prefix_errno2("realpath", argv[0]);
+			error = got_error_from_errno2("realpath", argv[0]);
 			goto done;
 		}
 		got_path_strip_trailing_slashes(path);
@@ -2350,7 +2350,7 @@ cmd_commit(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, cwd);
blob - 8c60816b6a8c0f225778df8ccd601ec24c75905d
blob + ac0dd60795055f7852165994cc7a04140e98ade4
--- include/got_error.h
+++ include/got_error.h
@@ -192,21 +192,21 @@ const struct got_error *got_error_msg(int, const char 
  * and an error message obtained from strerror(3), prefixed with a
  * string.
  */
-const struct got_error *got_error_prefix_errno(const char *);
+const struct got_error *got_error_from_errno(const char *);
 
 /*
  * Get a statically allocated error object with code GOT_ERR_ERRNO
  * and an error message obtained from strerror(3), prefixed with two
  * strings.
  */
-const struct got_error *got_error_prefix_errno2(const char *, const char *);
+const struct got_error *got_error_from_errno2(const char *, const char *);
 
 /*
  * Get a statically allocated error object with code GOT_ERR_ERRNO
  * and an error message obtained from strerror(3), prefixed with three
  * strings.
  */
-const struct got_error *got_error_prefix_errno3(const char *, const char *,
+const struct got_error *got_error_from_errno3(const char *, const char *,
     const char *);
 
 /*
@@ -219,7 +219,7 @@ const struct got_error *got_error_set_errno(int, const
 
 /*
  * If ferror(3) indicates an error status for the FILE, obtain an error
- * from got_error_prefix_errno(). Else, obtain the error via got_error()
+ * from got_error_from_errno(). Else, obtain the error via got_error()
  * with the error code provided in the second argument.
  */
 const struct got_error *got_ferror(FILE *, int);
blob - 7774b2b34372b9bb7b0a2cf749c68e2bf015b105
blob + b4f8b83d691aa50dc051471e60fc030370cb8298
--- lib/blame.c
+++ lib/blame.c
@@ -76,11 +76,11 @@ alloc_diff_offsets(struct got_blame_diff_offsets **dif
 
 	*diff_offsets = calloc(1, sizeof(**diff_offsets));
 	if (*diff_offsets == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*diff_offsets)->commit_id = got_object_id_dup(commit_id);
 	if ((*diff_offsets)->commit_id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		free_diff_offsets(*diff_offsets);
 		*diff_offsets = NULL;
 		return err;
@@ -275,7 +275,7 @@ blame_close(struct got_blame *blame)
 	struct got_blame_diff_offsets *diff_offsets;
 
 	if (blame->f && fclose(blame->f) != 0)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	free(blame->lines);
 	while (!SLIST_EMPTY(&blame->diff_offsets_list)) {
 		diff_offsets = SLIST_FIRST(&blame->diff_offsets_list);
@@ -322,11 +322,11 @@ blame_open(struct got_blame **blamep, const char *path
 
 	blame = calloc(1, sizeof(*blame));
 	if (blame == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	blame->f = got_opentemp();
 	if (blame->f == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 	err = got_object_blob_dump_to_file(NULL, &blame->nlines, blame->f,
@@ -336,7 +336,7 @@ blame_open(struct got_blame **blamep, const char *path
 
 	blame->lines = calloc(blame->nlines, sizeof(*blame->lines));
 	if (blame->lines == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -440,7 +440,7 @@ got_blame(const char *path, struct got_object_id *star
 	char *abspath;
 
 	if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
-		return got_error_prefix_errno2("asprintf", path);
+		return got_error_from_errno2("asprintf", path);
 
 	err = blame_open(&blame, abspath, start_commit_id, repo, NULL, NULL);
 	if (err) {
@@ -490,7 +490,7 @@ got_blame_incremental(const char *path, struct got_obj
 	char *abspath;
 
 	if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
-		return got_error_prefix_errno2("asprintf", path);
+		return got_error_from_errno2("asprintf", path);
 
 	err = blame_open(&blame, abspath, commit_id, repo, cb, arg);
 	free(abspath);
blob - 6f412d212911276fa303f51f02ccb124f9aa32bf
blob + 32d933f695c149153b60e1f90ede46c6fbb4a444
--- lib/buf.c
+++ lib/buf.c
@@ -297,20 +297,20 @@ buf_write(BUF *b, const char *path, mode_t mode)
 		if (errno == EACCES && unlink(path) != -1)
 			goto open;
 		else
-			return got_error_prefix_errno2("open", path);
+			return got_error_from_errno2("open", path);
 	}
 
 	if (buf_write_fd(b, fd) == -1) {
-		err = got_error_prefix_errno("buf_write_fd");
+		err = got_error_from_errno("buf_write_fd");
 		(void)unlink(path);
 		return err;
 	}
 
 	if (fchmod(fd, mode) < 0)
-		err = got_error_prefix_errno2("fchmod", path);
+		err = got_error_from_errno2("fchmod", path);
 
 	if (close(fd) != 0 && err == NULL)
-		err = got_error_prefix_errno2("close", path);
+		err = got_error_from_errno2("close", path);
 
 	return err;
 }
@@ -327,17 +327,17 @@ buf_write_stmp(BUF *b, char *template, struct wklhead 
 	int fd;
 
 	if ((fd = mkstemp(template)) == -1)
-		return got_error_prefix_errno("mkstemp");
+		return got_error_from_errno("mkstemp");
 
 	worklist_add(template, temp_files);
 
 	if (buf_write_fd(b, fd) == -1) {
-		err = got_error_prefix_errno("buf_write_fd");
+		err = got_error_from_errno("buf_write_fd");
 		(void)unlink(template);
 	}
 
 	if (close(fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 
 	return err;
 }
@@ -352,7 +352,7 @@ buf_grow(BUF *b, size_t len)
 	u_char *buf;
 	buf = reallocarray(b->cb_buf, 1, b->cb_size + len);
 	if (buf == NULL)
-		return got_error_prefix_errno("reallocarray");
+		return got_error_from_errno("reallocarray");
 	b->cb_buf = buf;
 	b->cb_size += len;
 	return NULL;
blob - 4139ee71bae49e6be558c89523897640d2432187
blob + d33c70cf31264d8857f215e6d0b539fd4fe38c40
--- lib/commit_graph.c
+++ lib/commit_graph.c
@@ -343,7 +343,7 @@ add_node(struct got_commit_graph_node **new_node, int 
 
 	node = calloc(1, sizeof(*node));
 	if (node == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	memcpy(&node->id, commit_id, sizeof(node->id));
 	node->timestamp = commit->committer_time;
@@ -405,7 +405,7 @@ got_commit_graph_open(struct got_commit_graph **graph,
 	*graph = alloc_graph(path);
 	if (*graph == NULL) {
 		got_object_commit_close(commit);
-		return got_error_prefix_errno("alloc_graph");
+		return got_error_from_errno("alloc_graph");
 	}
 
 	if (first_parent_traversal)
@@ -485,7 +485,7 @@ fetch_commits_from_open_branches(int *nfetched,
 		tips = recallocarray(graph->tips, graph->ntips, ntips,
 		    sizeof(*tips));
 		if (tips == NULL)
-			return got_error_prefix_errno("recallocarray");
+			return got_error_from_errno("recallocarray");
 		graph->tips = tips;
 		graph->ntips = ntips;
 	}
@@ -654,7 +654,7 @@ got_commit_graph_find_youngest_common_ancestor(struct 
 
 	commit_ids = got_object_idset_alloc();
 	if (commit_ids == NULL)
-		return got_error_prefix_errno("got_object_idset_alloc");
+		return got_error_from_errno("got_object_idset_alloc");
 
 	err = got_commit_graph_open(&graph, commit_id, "/", 1, repo);
 	if (err)
@@ -709,7 +709,7 @@ got_commit_graph_find_youngest_common_ancestor(struct 
 				if (*yca_id)
 					break;
 				else
-					err = got_error_prefix_errno(
+					err = got_error_from_errno(
 					    "got_object_id_up");
 				break;
 
@@ -724,7 +724,7 @@ got_commit_graph_find_youngest_common_ancestor(struct 
 				if (*yca_id)
 					break;
 				else
-					err = got_error_prefix_errno(
+					err = got_error_from_errno(
 					    "got_object_id_up");
 				break;
 
blob - 9132c5f35b58d61b77c0903aae8453c5c904e90e
blob + c7771b4a68393727bf41bbc946aa8bf453fc98b8
--- lib/deflate.c
+++ lib/deflate.c
@@ -47,10 +47,10 @@ got_deflate_init(struct got_deflate_buf *zb, uint8_t *
 	zerr = deflateInit(&zb->z, Z_DEFAULT_COMPRESSION);
 	if (zerr != Z_OK) {
 		if  (zerr == Z_ERRNO)
-			return got_error_prefix_errno("deflateInit");
+			return got_error_from_errno("deflateInit");
 		if  (zerr == Z_MEM_ERROR) {
 			errno = ENOMEM;
-			return got_error_prefix_errno("deflateInit");
+			return got_error_from_errno("deflateInit");
 		}
 		return got_error(GOT_ERR_COMPRESSION);
 	}
@@ -59,7 +59,7 @@ got_deflate_init(struct got_deflate_buf *zb, uint8_t *
 
 	zb->inbuf = calloc(1, zb->inlen);
 	if (zb->inbuf == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -67,7 +67,7 @@ got_deflate_init(struct got_deflate_buf *zb, uint8_t *
 	if (outbuf == NULL) {
 		zb->outbuf = calloc(1, zb->outlen);
 		if (zb->outbuf == NULL) {
-			err = got_error_prefix_errno("calloc");
+			err = got_error_from_errno("calloc");
 			goto done;
 		}
 		zb->flags |= GOT_DEFLATE_F_OWN_OUTBUF;
blob - ecf6c0c261edbaf1cf5ae722612ff9a3662b761c
blob + 2bed5349b29f99b725d2d2023834eb1bf00a304f
--- lib/delta.c
+++ lib/delta.c
@@ -187,7 +187,7 @@ static const struct got_error *
 copy_from_base(FILE *base_file, off_t offset, size_t size, FILE *outfile)
 {
 	if (fseeko(base_file, offset, SEEK_SET) != 0)
-		return got_error_prefix_errno("fseeko");
+		return got_error_from_errno("fseeko");
 
 	while (size > 0) {
 		uint8_t data[2048];
@@ -391,7 +391,7 @@ got_delta_apply(FILE *base_file, const uint8_t *delta_
 
 	if (memstream != NULL) {
 		if (fclose(memstream) != 0)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 		if (err == NULL) {
 			size_t n;
 			n = fwrite(memstream_buf, 1, memstream_size, outfile);
blob - 52b0c876d15b2cc0cd2b50756652b61ded1a1258
blob + e2adb32c5a3b01901892c591b614ba36ebf26127
--- lib/diff.c
+++ lib/diff.c
@@ -54,14 +54,14 @@ diff_blobs(struct got_blob_object *blob1, struct got_b
 	if (blob1) {
 		f1 = got_opentemp();
 		if (f1 == NULL)
-			return got_error_prefix_errno("got_opentemp");
+			return got_error_from_errno("got_opentemp");
 	} else
 		flags |= D_EMPTY1;
 
 	if (blob2) {
 		f2 = got_opentemp();
 		if (f2 == NULL) {
-			err = got_error_prefix_errno("got_opentemp");
+			err = got_error_from_errno("got_opentemp");
 			fclose(f1);
 			return err;
 		}
@@ -112,9 +112,9 @@ diff_blobs(struct got_blob_object *blob1, struct got_b
 	err = got_diffreg(&res, f1, f2, flags, &args, &ds, outfile, changes);
 done:
 	if (f1 && fclose(f1) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (f2 && fclose(f2) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	return err;
 }
 
@@ -143,7 +143,7 @@ got_diff_blob_file(struct got_blob_object *blob1, FILE
 	if (blob1) {
 		f1 = got_opentemp();
 		if (f1 == NULL)
-			return got_error_prefix_errno("got_opentemp");
+			return got_error_from_errno("got_opentemp");
 		idstr1 = got_object_blob_id_str(blob1, hex1, sizeof(hex1));
 		err = got_object_blob_dump_to_file(&size1, NULL, f1, blob1);
 		if (err)
@@ -179,7 +179,7 @@ got_diff_blob_file(struct got_blob_object *blob1, FILE
 	err = got_diffreg(&res, f1, f2, flags, &args, &ds, outfile, NULL);
 done:
 	if (f1 && fclose(f1) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	return err;
 }
 
@@ -191,7 +191,7 @@ got_diff_blob_lines_changed(struct got_diff_changes **
 
 	*changes = calloc(1, sizeof(**changes));
 	if (*changes == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	SIMPLEQ_INIT(&(*changes)->entries);
 
 	err = diff_blobs(blob1, blob2, NULL, NULL, 3, NULL, *changes);
@@ -513,7 +513,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 		te1 = SIMPLEQ_FIRST(&entries->head);
 		if (te1 && asprintf(&l1, "%s%s%s", label1, label1[0] ? "/" : "",
 		    te1->name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	}
 	if (tree2) {
 		const struct got_tree_entries *entries;
@@ -521,7 +521,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 		te2 = SIMPLEQ_FIRST(&entries->head);
 		if (te2 && asprintf(&l2, "%s%s%s", label2, label2[0] ? "/" : "",
 		    te2->name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	}
 
 	do {
@@ -535,7 +535,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 				if (te && asprintf(&l2, "%s%s%s", label2,
 				    label2[0] ? "/" : "", te->name) == -1)
 					return
-					    got_error_prefix_errno("asprintf");
+					    got_error_from_errno("asprintf");
 			}
 			err = diff_entry_old_new(te1, te, l1, l2, diff_context,
 			    repo, outfile);
@@ -552,12 +552,12 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 				if (asprintf(&l2, "%s%s%s", label2,
 				    label2[0] ? "/" : "", te->name) == -1)
 					return
-					    got_error_prefix_errno("asprintf");
+					    got_error_from_errno("asprintf");
 			} else {
 				if (asprintf(&l2, "%s%s%s", label2,
 				    label2[0] ? "/" : "", te2->name) == -1)
 					return
-					    got_error_prefix_errno("asprintf");
+					    got_error_from_errno("asprintf");
 			}
 			err = diff_entry_new_old(te2, te, l2, diff_context,
 			    repo, outfile);
@@ -572,7 +572,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 			if (te1 &&
 			    asprintf(&l1, "%s%s%s", label1,
 			    label1[0] ? "/" : "", te1->name) == -1)
-				return got_error_prefix_errno("asprintf");
+				return got_error_from_errno("asprintf");
 		}
 		free(l2);
 		l2 = NULL;
@@ -581,7 +581,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 			if (te2 &&
 			    asprintf(&l2, "%s%s%s", label2,
 			        label2[0] ? "/" : "", te2->name) == -1)
-				return got_error_prefix_errno("asprintf");
+				return got_error_from_errno("asprintf");
 		}
 	} while (te1 || te2);
 
blob - 8c259646842fa5061eae66ddd6cb0663f52071cb
blob + a04f3902152bc7dff80ea77f5d7132f765ac13b4
--- lib/diff3.c
+++ lib/diff3.c
@@ -185,7 +185,7 @@ diff_output(BUF *diffbuf, const char *fmt, ...)
 	i = vasprintf(&str, fmt, vap);
 	va_end(vap);
 	if (i == -1)
-		return got_error_prefix_errno("vasprintf");
+		return got_error_from_errno("vasprintf");
 	buf_append(&newsize, diffbuf, str, strlen(str));
 	free(str);
 	return NULL;
@@ -205,12 +205,12 @@ diffreg(BUF **d, const char *path1, const char *path2)
 
 	f1 = fopen(path1, "r");
 	if (f1 == NULL) {
-		err = got_error_prefix_errno2("fopen", path1);
+		err = got_error_from_errno2("fopen", path1);
 		goto done;
 	}
 	f2 = fopen(path2, "r");
 	if (f1 == NULL) {
-		err = got_error_prefix_errno2("fopen", path2);
+		err = got_error_from_errno2("fopen", path2);
 		goto done;
 	}
 
@@ -221,11 +221,11 @@ diffreg(BUF **d, const char *path1, const char *path2)
 	memset(&ds, 0, sizeof(ds));
 	/* XXX should stat buffers be passed in args instead of ds? */
 	if (stat(path1, &ds.stb1) == -1) {
-		err = got_error_prefix_errno2("stat", path1);
+		err = got_error_from_errno2("stat", path1);
 		goto done;
 	}
 	if (stat(path2, &ds.stb2) == -1) {
-		err = got_error_prefix_errno2("stat", path2);
+		err = got_error_from_errno2("stat", path2);
 		goto done;
 	}
 
@@ -241,24 +241,24 @@ diffreg(BUF **d, const char *path1, const char *path2)
 		goto done;
 
 	if (fflush(outfile) != 0) {
-		err = got_error_prefix_errno2("fflush", outpath);
+		err = got_error_from_errno2("fflush", outpath);
 		goto done;
 	}
 
 	*d = buf_load(outpath);
 	if (*d == NULL)
-		err = got_error_prefix_errno("buf_load");
+		err = got_error_from_errno("buf_load");
 done:
 	if (outpath) {
 		unlink(outpath);
 		free(outpath);
 	}
 	if (outfile && fclose(outfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (f1 && fclose(f1) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (f2 && fclose(f2) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	return err;
 }
 
@@ -284,7 +284,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char
 
 	d3s = calloc(1, sizeof(*d3s));
 	if (d3s == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	d3s->eflag = 3; /* default -E for compatibility with former RCS */
 	d3s->oflag = 1; /* default -E for compatibility with former RCS */
 
@@ -302,15 +302,15 @@ got_merge_diff3(int *overlapcnt, int outfd, const char
 	diffb = buf_alloc(128);
 
 	if (asprintf(&path1, "/tmp/got-diff1.XXXXXXXX") == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto out;
 	}
 	if (asprintf(&path2, "/tmp/got-diff2.XXXXXXXX") == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto out;
 	}
 	if (asprintf(&path3, "/tmp/got-diff3.XXXXXXXX") == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto out;
 	}
 
@@ -342,7 +342,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char
 	}
 
 	if (asprintf(&dp13, "/tmp/got-d13.XXXXXXXXXX") == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto out;
 	}
 	err = buf_write_stmp(d1, dp13, &temp_files);
@@ -353,7 +353,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char
 	d1 = NULL;
 
 	if (asprintf(&dp23, "/tmp/got-d23.XXXXXXXXXX") == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto out;
 	}
 	err = buf_write_stmp(d2, dp23, &temp_files);
@@ -402,11 +402,11 @@ out:
 
 	for (i = 0; i < nitems(d3s->fp); i++) {
 		if (d3s->fp[i] && fclose(d3s->fp[i]) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	if (err == NULL && diffb) {
 		if (buf_write_fd(diffb, outfd) < 0)
-			err = got_error_prefix_errno("buf_write_fd");
+			err = got_error_from_errno("buf_write_fd");
 		*overlapcnt = d3s->overlapcnt;
 	}
 	free(d3s);
@@ -445,14 +445,14 @@ diff3_internal(char *dp13, char *dp23, char *path1, ch
 		return err;
 
 	if ((d3s->fp[0] = fopen(path1, "r")) == NULL)
-		return got_error_prefix_errno2("fopen", path1);
+		return got_error_from_errno2("fopen", path1);
 	if ((d3s->fp[1] = fopen(path2, "r")) == NULL)
-		return got_error_prefix_errno2("fopen", path2);
+		return got_error_from_errno2("fopen", path2);
 	if ((d3s->fp[2] = fopen(path3, "r")) == NULL)
-		return got_error_prefix_errno2("fopen", path3);
+		return got_error_from_errno2("fopen", path3);
 
 	if (merge(m, n, d3s) < 0)
-		return got_error_prefix_errno("merge");
+		return got_error_from_errno("merge");
 	return NULL;
 }
 
@@ -585,7 +585,7 @@ readin(size_t *n, char *name, struct diff **dd, struct
 
 	d3s->fp[0] = fopen(name, "r");
 	if (d3s->fp[0] == NULL)
-		return got_error_prefix_errno2("fopen", name);
+		return got_error_from_errno2("fopen", name);
 	for (i = 0; (p = getchange(d3s->fp[0], d3s)); i++) {
 		if (i >= d3s->szchanges - 1) {
 			err = increase(d3s);
@@ -621,7 +621,7 @@ readin(size_t *n, char *name, struct diff **dd, struct
 	}
 
 	if (fclose(d3s->fp[0]) != 0)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 
 	*n = i;
 	return err;
@@ -982,25 +982,25 @@ increase(struct diff3_state *d3s)
 
 	d = reallocarray(d3s->d13, newsz, sizeof(*d3s->d13));
 	if (d == NULL)
-		return got_error_prefix_errno("reallocarray");
+		return got_error_from_errno("reallocarray");
 	d3s->d13 = d;
 	memset(d3s->d13 + d3s->szchanges, 0, incr * sizeof(*d3s->d13));
 
 	d = reallocarray(d3s->d23, newsz, sizeof(*d3s->d23));
 	if (d == NULL)
-		return got_error_prefix_errno("reallocarray");
+		return got_error_from_errno("reallocarray");
 	d3s->d23 = d;
 	memset(d3s->d23 + d3s->szchanges, 0, incr * sizeof(*d3s->d23));
 
 	d = reallocarray(d3s->de, newsz, sizeof(*d3s->de));
 	if (d == NULL)
-		return got_error_prefix_errno("reallocarray");
+		return got_error_from_errno("reallocarray");
 	d3s->de = d;
 	memset(d3s->de + d3s->szchanges, 0, incr * sizeof(*d3s->de));
 
 	s = reallocarray(d3s->overlap, newsz, sizeof(*d3s->overlap));
 	if (s == NULL)
-		return got_error_prefix_errno("reallocarray");
+		return got_error_from_errno("reallocarray");
 	d3s->overlap = s;
 	memset(d3s->overlap + d3s->szchanges, 0, incr * sizeof(*d3s->overlap));
 	d3s->szchanges = newsz;
blob - 87f54533f4efc138efcb8ffe4b2043bae52623cd
blob + 5f4d297389d1fcdcdda02f1929bea4e8ecd572bf
--- lib/diffoffset.c
+++ lib/diffoffset.c
@@ -64,11 +64,11 @@ got_diffoffset_alloc(struct got_diffoffset_chunks **ch
 
 	first = alloc_chunk(0, 0);
 	if (first == NULL)
-		return got_error_prefix_errno("alloc_chunk");
+		return got_error_from_errno("alloc_chunk");
 
 	*chunks = calloc(1, sizeof(**chunks));
 	if (*chunks == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		free(first);
 		return err;
 	}
@@ -100,13 +100,13 @@ got_diffoffset_add(struct got_diffoffset_chunks *chunk
 
 	chunk1 = alloc_chunk(old_lineno, new_lineno - old_lineno);
 	if (chunk1 == NULL)
-		return got_error_prefix_errno("alloc_chunk");
+		return got_error_from_errno("alloc_chunk");
 
 	chunk2 = alloc_chunk(old_lineno + old_length,
 	    new_lineno - old_lineno + new_length - old_length);
 	if (chunk2 == NULL) {
 		const struct got_error *err =
-		    got_error_prefix_errno("alloc_chunk");
+		    got_error_from_errno("alloc_chunk");
 		free(chunk1);
 		return err;
 	}
blob - fa4938c7bfaefec7a8494a0d6081ac999207a3e8
blob + e48ec98a28c616599460c2ff17bc027b86e2cddb
--- lib/diffreg.c
+++ lib/diffreg.c
@@ -293,7 +293,7 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 	if (flags & D_EMPTY1) {
 		f1 = fopen(_PATH_DEVNULL, "r");
 		if (f1 == NULL) {
-			err = got_error_prefix_errno2("fopen", _PATH_DEVNULL);
+			err = got_error_from_errno2("fopen", _PATH_DEVNULL);
 			goto closem;
 		}
 	}
@@ -305,7 +305,7 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 	if (flags & D_EMPTY2) {
 		f2 = fopen(_PATH_DEVNULL, "r");
 		if (f2 == NULL) {
-			err = got_error_prefix_errno2("fopen", _PATH_DEVNULL);
+			err = got_error_from_errno2("fopen", _PATH_DEVNULL);
 			goto closem;
 		}
 	} else if (f2 == NULL) {
@@ -331,11 +331,11 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 		goto closem;
 	}
 	if (prepare(ds, 0, f1, ds->stb1.st_size, flags)) {
-		err = got_error_prefix_errno("prepare");
+		err = got_error_from_errno("prepare");
 		goto closem;
 	}
 	if (prepare(ds, 1, f2, ds->stb2.st_size, flags)) {
-		err = got_error_prefix_errno("prepare");
+		err = got_error_from_errno("prepare");
 		goto closem;
 	}
 
@@ -347,44 +347,44 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 	equiv(ds->sfile[0], ds->slen[0], ds->sfile[1], ds->slen[1], ds->member);
 	p = reallocarray(ds->member, ds->slen[1] + 2, sizeof(*ds->member));
 	if (p == NULL) {
-		err = got_error_prefix_errno("reallocarray");
+		err = got_error_from_errno("reallocarray");
 		goto closem;
 	}
 	ds->member = p;
 
 	ds->class = (int *)ds->file[0];
 	if (unsort(ds->sfile[0], ds->slen[0], ds->class)) {
-		err = got_error_prefix_errno("unsort");
+		err = got_error_from_errno("unsort");
 		goto closem;
 	}
 	p = reallocarray(ds->class, ds->slen[0] + 2, sizeof(*ds->class));
 	if (p == NULL) {
-		err = got_error_prefix_errno("reallocarray");
+		err = got_error_from_errno("reallocarray");
 		goto closem;
 	}
 	ds->class = p;
 
 	ds->klist = calloc(ds->slen[0] + 2, sizeof(*ds->klist));
 	if (ds->klist == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto closem;
 	}
 	ds->clen = 0;
 	ds->clistlen = 100;
 	ds->clist = calloc(ds->clistlen, sizeof(*ds->clist));
 	if (ds->clist == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto closem;
 	}
 	i = stone(ds, ds->class, ds->slen[0], ds->member, ds->klist, flags);
 	if (i < 0) {
-		err = got_error_prefix_errno("stone");
+		err = got_error_from_errno("stone");
 		goto closem;
 	}
 
 	p = reallocarray(ds->J, ds->len[0] + 2, sizeof(*ds->J));
 	if (p == NULL) {
-		err = got_error_prefix_errno("reallocarray");
+		err = got_error_from_errno("reallocarray");
 		goto closem;
 	}
 	ds->J = p;
@@ -392,20 +392,20 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags,
 
 	lp = reallocarray(ds->ixold, ds->len[0] + 2, sizeof(*ds->ixold));
 	if (lp == NULL) {
-		err = got_error_prefix_errno("reallocarray");
+		err = got_error_from_errno("reallocarray");
 		goto closem;
 	}
 	ds->ixold = lp;
 	lp = reallocarray(ds->ixnew, ds->len[1] + 2, sizeof(*ds->ixnew));
 	if (lp == NULL) {
-		err = got_error_prefix_errno("reallocarray");
+		err = got_error_from_errno("reallocarray");
 		goto closem;
 	}
 	ds->ixnew = lp;
 	check(ds, f1, f2, flags);
 	if (output(outfile, changes, ds, args, args->label[0], f1,
 	    args->label[1], f2, flags))
-		err = got_error_prefix_errno("output");
+		err = got_error_from_errno("output");
 closem:
 	free(ds->J);
 	free(ds->member);
blob - 1fd38ce6fb96c6f9744cad5dbd47178a40e6b420
blob + c3af78d19c9dcfb46c349c76e439e211bbcbe37f
--- lib/error.c
+++ lib/error.c
@@ -68,7 +68,7 @@ got_error_msg(int code, const char *msg)
 }
 
 const struct got_error *
-got_error_prefix_errno(const char *prefix)
+got_error_from_errno(const char *prefix)
 {
 	static struct got_error err;
 	static char err_msg[MAXPATHLEN + 20];
@@ -82,7 +82,7 @@ got_error_prefix_errno(const char *prefix)
 }
 
 const struct got_error *
-got_error_prefix_errno2(const char *prefix, const char *prefix2)
+got_error_from_errno2(const char *prefix, const char *prefix2)
 {
 	static struct got_error err;
 	static char err_msg[(MAXPATHLEN * 2) + 20];
@@ -96,7 +96,7 @@ got_error_prefix_errno2(const char *prefix, const char
 }
 
 const struct got_error *
-got_error_prefix_errno3(const char *prefix, const char *prefix2,
+got_error_from_errno3(const char *prefix, const char *prefix2,
     const char *prefix3)
 {
 	static struct got_error err;
@@ -114,14 +114,14 @@ const struct got_error *
 got_error_set_errno(int code, const char *prefix)
 {
 	errno = code;
-	return got_error_prefix_errno(prefix);
+	return got_error_from_errno(prefix);
 }
 
 const struct got_error *
 got_ferror(FILE *f, int code)
 {
 	if (ferror(f))
-		return got_error_prefix_errno("");
+		return got_error_from_errno("");
 	return got_error(code);
 }
 
blob - 61562ca737ba48acc9ec864ecdc25796636c48e3
blob + 8ff467458d80b3a0f400b0b4b668affadbc2a12a
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -60,7 +60,7 @@ got_fileindex_entry_update(struct got_fileindex_entry 
 
 	if (lstat(ondisk_path, &sb) != 0) {
 		if ((entry->flags & GOT_FILEIDX_F_NO_FILE_ON_DISK) == 0)
-			return got_error_prefix_errno2("lstat", ondisk_path);
+			return got_error_from_errno2("lstat", ondisk_path);
 	} else {
 		if (sb.st_mode & S_IFDIR)
 			return got_error_set_errno(EISDIR, ondisk_path);
@@ -116,11 +116,11 @@ got_fileindex_entry_alloc(struct got_fileindex_entry *
 
 	*entry = calloc(1, sizeof(**entry));
 	if (*entry == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*entry)->path = strdup(relpath);
 	if ((*entry)->path == NULL) {
-		const struct got_error *err = got_error_prefix_errno("strdup");
+		const struct got_error *err = got_error_from_errno("strdup");
 		free(*entry);
 		*entry = NULL;
 		return err;
@@ -394,7 +394,7 @@ got_fileindex_write(struct got_fileindex *fileindex, F
 		return got_ferror(outfile, GOT_ERR_IO);
 
 	if (fflush(outfile) != 0)
-		return got_error_prefix_errno("fflush");
+		return got_error_from_errno("fflush");
 
 	return NULL;
 }
@@ -447,7 +447,7 @@ read_fileindex_path(char **path, SHA1_CTX *ctx, FILE *
 
 	*path = malloc(totlen);
 	if (*path == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	do {
 		n = fread(buf, 1, sizeof(buf), infile);
@@ -456,7 +456,7 @@ read_fileindex_path(char **path, SHA1_CTX *ctx, FILE *
 		if (len + sizeof(buf) > totlen) {
 			char *p = reallocarray(*path, totlen + sizeof(buf), 1);
 			if (p == NULL) {
-				err = got_error_prefix_errno("reallocarray");
+				err = got_error_from_errno("reallocarray");
 				break;
 			}
 			totlen += sizeof(buf);
@@ -486,7 +486,7 @@ read_fileindex_entry(struct got_fileindex_entry **entr
 
 	entry = calloc(1, sizeof(*entry));
 	if (entry == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	err = read_fileindex_val64(&entry->ctime_sec, ctx, infile);
 	if (err)
@@ -640,7 +640,7 @@ walk_tree(struct got_tree_entry **next, struct got_fil
 
 		if (asprintf(&subpath, "%s%s%s", path,
 		    path[0] == '\0' ? "" : "/", te->name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 
 		err = got_object_open_as_tree(&subtree, repo, te->id);
 		if (err) {
@@ -679,7 +679,7 @@ diff_fileindex_tree(struct got_fileindex *fileindex,
 			char *te_path;
 			int cmp;
 			if (asprintf(&te_path, "%s/%s", path, te->name) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				break;
 			}
 			cmp = got_path_cmp((*ie)->path, te_path);
@@ -781,18 +781,18 @@ walk_dir(struct got_pathlist_entry **next, struct got_
 
 		if (asprintf(&subpath, "%s%s%s", path,
 		    path[0] == '\0' ? "" : "/", de->d_name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 
 		if (asprintf(&subdirpath, "%s/%s", rootpath, subpath) == -1) {
 			free(subpath);
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 		}
 
 		subdir = opendir(subdirpath);
 		if (subdir == NULL) {
 			free(subpath);
 			free(subdirpath);
-			return got_error_prefix_errno2("opendir", subdirpath);
+			return got_error_from_errno2("opendir", subdirpath);
 		}
 
 		err = diff_fileindex_dir(fileindex, ie, subdir, rootpath,
@@ -829,12 +829,12 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 
 		de = malloc(sizeof(struct dirent) + NAME_MAX + 1);
 		if (de == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 
 		if (readdir_r(dir, de, &dep) != 0) {
-			err = got_error_prefix_errno("readdir_r");
+			err = got_error_from_errno("readdir_r");
 			free(de);
 			goto done;
 		}
@@ -871,7 +871,7 @@ diff_fileindex_dir(struct got_fileindex *fileindex,
 			de = dle->data;
 			if (asprintf(&de_path, "%s/%s", path,
 			    de->d_name) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				break;
 			}
 			cmp = got_path_cmp((*ie)->path, de_path);
blob - a23e868b2e9cfcfec8cd0909dd3a4d76eb28ab23
blob + cf569abc9136ea5fefdadf1a9a9fde8eaf66ab66
--- lib/inflate.c
+++ lib/inflate.c
@@ -47,10 +47,10 @@ got_inflate_init(struct got_inflate_buf *zb, uint8_t *
 	zerr = inflateInit(&zb->z);
 	if (zerr != Z_OK) {
 		if  (zerr == Z_ERRNO)
-			return got_error_prefix_errno("inflateInit");
+			return got_error_from_errno("inflateInit");
 		if  (zerr == Z_MEM_ERROR) {
 			errno = ENOMEM;
-			return got_error_prefix_errno("inflateInit");
+			return got_error_from_errno("inflateInit");
 		}
 		return got_error(GOT_ERR_DECOMPRESSION);
 	}
@@ -59,7 +59,7 @@ got_inflate_init(struct got_inflate_buf *zb, uint8_t *
 
 	zb->inbuf = calloc(1, zb->inlen);
 	if (zb->inbuf == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -67,7 +67,7 @@ got_inflate_init(struct got_inflate_buf *zb, uint8_t *
 	if (outbuf == NULL) {
 		zb->outbuf = calloc(1, zb->outlen);
 		if (zb->outbuf == NULL) {
-			err = got_error_prefix_errno("calloc");
+			err = got_error_from_errno("calloc");
 			goto done;
 		}
 		zb->flags |= GOT_INFLATE_F_OWN_OUTBUF;
@@ -134,7 +134,7 @@ got_inflate_read_fd(struct got_inflate_buf *zb, int fd
 		if (z->avail_in == 0) {
 			ssize_t n = read(fd, zb->inbuf, zb->inlen);
 			if (n < 0)
-				return got_error_prefix_errno("read");
+				return got_error_from_errno("read");
 			else if (n == 0) {
 				/* EOF */
 				ret = Z_STREAM_END;
@@ -220,7 +220,7 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, F
 
 	*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
 	if (*outbuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
 	if (err)
 		return err;
@@ -237,7 +237,7 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, F
 			newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
 			   GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {
-				err = got_error_prefix_errno("recallocarray");
+				err = got_error_from_errno("recallocarray");
 				free(*outbuf);
 				*outbuf = NULL;
 				*outlen = 0;
@@ -265,7 +265,7 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen
 
 	*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
 	if (*outbuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
 	if (err)
 		goto done;
@@ -282,7 +282,7 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen
 			newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
 			    GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {
-				err = got_error_prefix_errno("recallocarray");
+				err = got_error_from_errno("recallocarray");
 				free(*outbuf);
 				*outbuf = NULL;
 				*outlen = 0;
@@ -311,7 +311,7 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl
 
 	*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
 	if (*outbuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
 	if (err) {
 		free(*outbuf);
@@ -336,7 +336,7 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl
 			newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
 			    GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {
-				err = got_error_prefix_errno("recallocarray");
+				err = got_error_from_errno("recallocarray");
 				free(*outbuf);
 				*outbuf = NULL;
 				*outlen = 0;
@@ -373,7 +373,7 @@ got_inflate_to_fd(size_t *outlen, FILE *infile, int ou
 			ssize_t n;
 			n = write(outfd, zb.outbuf, avail);
 			if (n != avail) {
-				err = got_error_prefix_errno("write");
+				err = got_error_from_errno("write");
 				goto done;
 			}
 			*outlen += avail;
@@ -383,7 +383,7 @@ got_inflate_to_fd(size_t *outlen, FILE *infile, int ou
 done:
 	if (err == NULL) {
 		if (lseek(outfd, SEEK_SET, 0) == -1)
-			err = got_error_prefix_errno("lseek");
+			err = got_error_from_errno("lseek");
 	}
 	got_inflate_end(&zb);
 	return err;
blob - 9c2a16b3b0c849368cfbbf4060db8bf432199e77
blob + bc4cf864a87ae6ca01a4fa56e150cef5110d17aa
--- lib/lockfile.c
+++ lib/lockfile.c
@@ -38,17 +38,17 @@ got_lockfile_lock(struct got_lockfile **lf, const char
 
 	*lf = calloc(1, sizeof(**lf));
 	if (*lf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	(*lf)->fd = -1;
 
 	(*lf)->locked_path = strdup(path);
 	if ((*lf)->locked_path == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
 	if (asprintf(&(*lf)->path, "%s%s", path, GOT_LOCKFILE_SUFFIX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -59,7 +59,7 @@ got_lockfile_lock(struct got_lockfile **lf, const char
 		if ((*lf)->fd != -1)
 			break;
 		if (errno != EEXIST) {
-			err = got_error_prefix_errno2("open", (*lf)->path);
+			err = got_error_from_errno2("open", (*lf)->path);
 			goto done;
 		}
 		sleep(1);
@@ -81,9 +81,9 @@ got_lockfile_unlock(struct got_lockfile *lf)
 	const struct got_error *err = NULL;
 
 	if (lf->path && lf->fd != -1 && unlink(lf->path) != 0)
-		err = got_error_prefix_errno("unlink");
+		err = got_error_from_errno("unlink");
 	if (lf->fd != -1 && close(lf->fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	free(lf->path);
 	free(lf->locked_path);
 	free(lf);
blob - 0c9e8d05afb85118159e6aee19002ca969c23612
blob + d781faafd2c372bd139bef6f3b37d18ffca12f5b
--- lib/object.c
+++ lib/object.c
@@ -118,7 +118,7 @@ got_object_get_path(char **path, struct got_object_id 
 	*path = NULL;
 
 	if (path_objects == NULL)
-		return got_error_prefix_errno("got_repo_get_path_objects");
+		return got_error_from_errno("got_repo_get_path_objects");
 
 	err = got_object_id_str(&hex, id);
 	if (err)
@@ -126,7 +126,7 @@ got_object_get_path(char **path, struct got_object_id 
 
 	if (asprintf(path, "%s/%.2x/%s", path_objects,
 	    id->sha1[0], hex + 2) == -1)
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 
 done:
 	free(hex);
@@ -146,7 +146,7 @@ open_loose_object(int *fd, struct got_object_id *id,
 		return err;
 	*fd = open(path, O_RDONLY | O_NOFOLLOW);
 	if (*fd == -1) {
-		err = got_error_prefix_errno2("open", path);
+		err = got_error_from_errno2("open", path);
 		goto done;
 	}
 done:
@@ -166,7 +166,7 @@ get_packfile_path(char **path_packfile, struct got_pac
 
 	*path_packfile = malloc(size);
 	if (*path_packfile == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	/* Copy up to and excluding ".idx". */
 	if (strlcpy(*path_packfile, packidx->path_packidx,
@@ -220,7 +220,7 @@ request_packed_object(struct got_object **obj, struct 
 
 	(*obj)->path_packfile = strdup(pack->path_packfile);
 	if ((*obj)->path_packfile == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		return err;
 	}
 	memcpy(&(*obj)->id, id, sizeof((*obj)->id));
@@ -238,23 +238,23 @@ start_pack_privsep_child(struct got_pack *pack, struct
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	pack->privsep_child = calloc(1, sizeof(*pack->privsep_child));
 	if (pack->privsep_child == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		free(ibuf);
 		return err;
 	}
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
-		err = got_error_prefix_errno("socketpair");
+		err = got_error_from_errno("socketpair");
 		goto done;
 	}
 
 	pid = fork();
 	if (pid == -1) {
-		err = got_error_prefix_errno("fork");
+		err = got_error_from_errno("fork");
 		goto done;
 	} else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_PACK,
@@ -263,7 +263,7 @@ start_pack_privsep_child(struct got_pack *pack, struct
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	pack->privsep_child->imsg_fd = imsg_fds[0];
 	pack->privsep_child->pid = pid;
 	imsg_init(ibuf, imsg_fds[0]);
@@ -368,14 +368,14 @@ read_object_header_privsep(struct got_object **obj, st
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
-		return got_error_prefix_errno("socketpair");
+		return got_error_from_errno("socketpair");
 
 	pid = fork();
 	if (pid == -1)
-		return got_error_prefix_errno("fork");
+		return got_error_from_errno("fork");
 	else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_OBJECT,
 		    repo->path);
@@ -383,7 +383,7 @@ read_object_header_privsep(struct got_object **obj, st
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd =
 	    imsg_fds[0];
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].pid = pid;
@@ -425,7 +425,7 @@ got_object_open(struct got_object **obj, struct got_re
 		if (errno == ENOENT)
 			err = got_error_no_obj(id);
 		else
-			err = got_error_prefix_errno2("open", path);
+			err = got_error_from_errno2("open", path);
 		goto done;
 	} else {
 		err = read_object_header_privsep(obj, repo, fd);
@@ -468,7 +468,7 @@ got_object_resolve_id_str(struct got_object_id **id,
 	*id = got_object_id_dup(got_object_get_id(obj));
 	got_object_close(obj);
 	if (*id == NULL)
-		return got_error_prefix_errno("got_object_id_dup");
+		return got_error_from_errno("got_object_id_dup");
 
 	return NULL;
 }
@@ -533,14 +533,14 @@ read_commit_privsep(struct got_commit_object **commit,
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
-		return got_error_prefix_errno("socketpair");
+		return got_error_from_errno("socketpair");
 
 	pid = fork();
 	if (pid == -1)
-		return got_error_prefix_errno("fork");
+		return got_error_from_errno("fork");
 	else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_COMMIT,
 		    repo->path);
@@ -548,7 +548,7 @@ read_commit_privsep(struct got_commit_object **commit,
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd =
 	    imsg_fds[0];
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].pid = pid;
@@ -638,11 +638,11 @@ got_object_qid_alloc(struct got_object_qid **qid, stru
 
 	*qid = calloc(1, sizeof(**qid));
 	if (*qid == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*qid)->id = got_object_id_dup(id);
 	if ((*qid)->id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		got_object_qid_free(*qid);
 		*qid = NULL;
 		return err;
@@ -711,14 +711,14 @@ read_tree_privsep(struct got_tree_object **tree, int o
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
-		return got_error_prefix_errno("socketpair");
+		return got_error_from_errno("socketpair");
 
 	pid = fork();
 	if (pid == -1)
-		return got_error_prefix_errno("fork");
+		return got_error_from_errno("fork");
 	else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_TREE,
 		    repo->path);
@@ -726,7 +726,7 @@ read_tree_privsep(struct got_tree_object **tree, int o
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].imsg_fd =
 	    imsg_fds[0];
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].pid = pid;
@@ -826,14 +826,14 @@ request_packed_blob(uint8_t **outbuf, size_t *size, si
 
 	basefd = got_opentempfd();
 	if (basefd == -1)
-		return got_error_prefix_errno("got_opentempfd");
+		return got_error_from_errno("got_opentempfd");
 	accumfd = got_opentempfd();
 	if (accumfd == -1)
-		return got_error_prefix_errno("got_opentempfd");
+		return got_error_from_errno("got_opentempfd");
 
 	outfd_child = dup(outfd);
 	if (outfd_child == -1)
-		return got_error_prefix_errno("dup");
+		return got_error_from_errno("dup");
 
 	err = got_privsep_send_blob_req(pack->privsep_child->ibuf, -1, id, idx);
 	if (err)
@@ -865,7 +865,7 @@ request_packed_blob(uint8_t **outbuf, size_t *size, si
 		return err;
 
 	if (lseek(outfd, SEEK_SET, 0) == -1)
-		err = got_error_prefix_errno("lseek");
+		err = got_error_from_errno("lseek");
 
 	return err;
 }
@@ -896,7 +896,7 @@ request_blob(uint8_t **outbuf, size_t *size, size_t *h
 
 	outfd_child = dup(outfd);
 	if (outfd_child == -1)
-		return got_error_prefix_errno("dup");
+		return got_error_from_errno("dup");
 
 	err = got_privsep_send_blob_req(ibuf, infd, NULL, -1);
 	if (err)
@@ -911,7 +911,7 @@ request_blob(uint8_t **outbuf, size_t *size, size_t *h
 		return err;
 
 	if (lseek(outfd, SEEK_SET, 0) == -1)
-		return got_error_prefix_errno("lseek");
+		return got_error_from_errno("lseek");
 
 	return err;
 }
@@ -931,14 +931,14 @@ read_blob_privsep(uint8_t **outbuf, size_t *size, size
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
-		return got_error_prefix_errno("socketpair");
+		return got_error_from_errno("socketpair");
 
 	pid = fork();
 	if (pid == -1)
-		return got_error_prefix_errno("fork");
+		return got_error_from_errno("fork");
 	else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_BLOB,
 		    repo->path);
@@ -946,7 +946,7 @@ read_blob_privsep(uint8_t **outbuf, size_t *size, size
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].imsg_fd =
 	    imsg_fds[0];
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].pid = pid;
@@ -971,15 +971,15 @@ open_blob(struct got_blob_object **blob, struct got_re
 
 	*blob = calloc(1, sizeof(**blob));
 	if (*blob == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	outfd = got_opentempfd();
 	if (outfd == -1)
-		return got_error_prefix_errno("got_opentempfd");
+		return got_error_from_errno("got_opentempfd");
 
 	(*blob)->read_buf = malloc(blocksize);
 	if ((*blob)->read_buf == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		goto done;
 	}
 
@@ -1019,18 +1019,18 @@ open_blob(struct got_blob_object **blob, struct got_re
 
 	if (outbuf) {
 		if (close(outfd) != 0 && err == NULL)
-			err = got_error_prefix_errno("close");
+			err = got_error_from_errno("close");
 		outfd = -1;
 		(*blob)->f = fmemopen(outbuf, size, "rb");
 		if ((*blob)->f == NULL) {
-			err = got_error_prefix_errno("fmemopen");
+			err = got_error_from_errno("fmemopen");
 			free(outbuf);
 			goto done;
 		}
 		(*blob)->data = outbuf;
 	} else {
 		if (fstat(outfd, &sb) == -1) {
-			err = got_error_prefix_errno("fstat");
+			err = got_error_from_errno("fstat");
 			goto done;
 		}
 
@@ -1041,7 +1041,7 @@ open_blob(struct got_blob_object **blob, struct got_re
 
 		(*blob)->f = fdopen(outfd, "rb");
 		if ((*blob)->f == NULL) {
-			err = got_error_prefix_errno("fdopen");
+			err = got_error_from_errno("fdopen");
 			close(outfd);
 			outfd = -1;
 			goto done;
@@ -1084,7 +1084,7 @@ got_object_blob_close(struct got_blob_object *blob)
 	const struct got_error *err = NULL;
 	free(blob->read_buf);
 	if (blob->f && fclose(blob->f) != 0)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	free(blob->data);
 	free(blob);
 	return err;
@@ -1158,7 +1158,7 @@ got_object_blob_dump_to_file(size_t *total_len, int *n
 	} while (len != 0);
 
 	if (fflush(outfile) != 0)
-		return got_error_prefix_errno("fflush");
+		return got_error_from_errno("fflush");
 	rewind(outfile);
 
 	return NULL;
@@ -1224,14 +1224,14 @@ read_tag_privsep(struct got_tag_object **tag, int obj_
 
 	ibuf = calloc(1, sizeof(*ibuf));
 	if (ibuf == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
-		return got_error_prefix_errno("socketpair");
+		return got_error_from_errno("socketpair");
 
 	pid = fork();
 	if (pid == -1)
-		return got_error_prefix_errno("fork");
+		return got_error_from_errno("fork");
 	else if (pid == 0) {
 		exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_TAG,
 		    repo->path);
@@ -1239,7 +1239,7 @@ read_tag_privsep(struct got_tag_object **tag, int obj_
 	}
 
 	if (close(imsg_fds[1]) != 0)
-		return got_error_prefix_errno("close");
+		return got_error_from_errno("close");
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].imsg_fd =
 	    imsg_fds[0];
 	repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].pid = pid;
@@ -1382,7 +1382,7 @@ got_object_id_by_path(struct got_object_id **id, struc
 	if (path[1] == '\0') {
 		*id = got_object_id_dup(commit->tree_id);
 		if (*id == NULL)
-			err = got_error_prefix_errno("got_object_id_dup");
+			err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 
@@ -1430,7 +1430,7 @@ got_object_id_by_path(struct got_object_id **id, struc
 	if (te) {
 		*id = got_object_id_dup(te->id);
 		if (*id == NULL)
-			return got_error_prefix_errno("got_object_id_dup");
+			return got_error_from_errno("got_object_id_dup");
 	} else
 		err = got_error(GOT_ERR_NO_TREE_ENTRY);
 done:
@@ -1544,18 +1544,18 @@ got_object_tree_entry_dup(struct got_tree_entry **new_
 
 	*new_te = calloc(1, sizeof(**new_te));
 	if (*new_te == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*new_te)->mode = te->mode;
 	(*new_te)->name = strdup(te->name);
 	if ((*new_te)->name == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
 	(*new_te)->id = got_object_id_dup(te->id);
 	if ((*new_te)->id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 done:
blob - 17731e448a0b3bfaf078194ce96ece804815b588
blob + d2e350b5272e2d79eb6f86e0568a4fcbcc2d3f5b
--- lib/object_cache.c
+++ lib/object_cache.c
@@ -45,7 +45,7 @@ got_object_cache_init(struct got_object_cache *cache,
 
 	cache->idset = got_object_idset_alloc();
 	if (cache->idset == NULL)
-		return got_error_prefix_errno("got_object_idset_alloc");
+		return got_error_from_errno("got_object_idset_alloc");
 
 	cache->type = type;
 	switch (type) {
@@ -98,7 +98,7 @@ got_object_cache_add(struct got_object_cache *cache, s
 
 	ce = malloc(sizeof(*ce));
 	if (ce == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 	memcpy(&ce->id, id, sizeof(ce->id));
 	switch (cache->type) {
 	case GOT_OBJECT_CACHE_TYPE_OBJ:
blob - 0a94c6561d897225828b8b9de80c968839fb55ae
blob + 5560dd333aedc9926925e144ccd43130927d1a07
--- lib/object_create.c
+++ lib/object_create.c
@@ -84,25 +84,25 @@ create_object_file(struct got_object_id *id, FILE *con
 		goto done;
 
 	if (rename(tmppath, objpath) != 0) {
-		err = got_error_prefix_errno3("rename", tmppath, objpath);
+		err = got_error_from_errno3("rename", tmppath, objpath);
 		goto done;
 	}
 	free(tmppath);
 	tmppath = NULL;
 
 	if (chmod(objpath, GOT_DEFAULT_FILE_MODE) != 0) {
-		err = got_error_prefix_errno2("chmod", objpath);
+		err = got_error_from_errno2("chmod", objpath);
 		goto done;
 	}
 done:
 	free(objpath);
 	if (tmppath) {
 		if (unlink(tmppath) != 0 && err == NULL)
-			err = got_error_prefix_errno2("unlink", tmppath);
+			err = got_error_from_errno2("unlink", tmppath);
 		free(tmppath);
 	}
 	if (tmpfile && fclose(tmpfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (lf)
 		unlock_err = got_lockfile_unlock(lf);
 	return err ? err : unlock_err;
@@ -126,16 +126,16 @@ got_object_blob_create(struct got_object_id **id, cons
 
 	fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW);
 	if (fd == -1)
-		return got_error_prefix_errno2("open", ondisk_path);
+		return got_error_from_errno2("open", ondisk_path);
 
 	if (fstat(fd, &sb) == -1) {
-		err = got_error_prefix_errno2("fstat", ondisk_path);
+		err = got_error_from_errno2("fstat", ondisk_path);
 		goto done;
 	}
 
 	if (asprintf(&header, "%s %lld", GOT_OBJ_LABEL_BLOB,
 		sb.st_size) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	headerlen = strlen(header) + 1;
@@ -143,7 +143,7 @@ got_object_blob_create(struct got_object_id **id, cons
 
 	blobfile = got_opentemp();
 	if (blobfile == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 
@@ -158,7 +158,7 @@ got_object_blob_create(struct got_object_id **id, cons
 
 		inlen = read(fd, buf, sizeof(buf));
 		if (inlen == -1) {
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 			goto done;
 		}
 		if (inlen == 0)
@@ -173,13 +173,13 @@ got_object_blob_create(struct got_object_id **id, cons
 
 	*id = malloc(sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
 
 	if (fflush(blobfile) != 0) {
-		err = got_error_prefix_errno("fflush");
+		err = got_error_from_errno("fflush");
 		goto done;
 	}
 	rewind(blobfile);
@@ -188,9 +188,9 @@ got_object_blob_create(struct got_object_id **id, cons
 done:
 	free(header);
 	if (fd != -1 && close(fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	if (blobfile && fclose(blobfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
 		*id = NULL;
@@ -233,7 +233,7 @@ got_object_tree_create(struct got_object_id **id,
 	}
 
 	if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_TREE, len) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	headerlen = strlen(header) + 1;
@@ -241,7 +241,7 @@ got_object_tree_create(struct got_object_id **id,
 
 	treefile = got_opentemp();
 	if (treefile == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 
@@ -282,13 +282,13 @@ got_object_tree_create(struct got_object_id **id,
 
 	*id = malloc(sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
 
 	if (fflush(treefile) != 0) {
-		err = got_error_prefix_errno("fflush");
+		err = got_error_from_errno("fflush");
 		goto done;
 	}
 	rewind(treefile);
@@ -297,7 +297,7 @@ got_object_tree_create(struct got_object_id **id,
 done:
 	free(header);
 	if (treefile && fclose(treefile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
 		*id = NULL;
@@ -327,13 +327,13 @@ got_object_commit_create(struct got_object_id **id,
 
 	if (asprintf(&author_str, "%s%s %lld +0000\n",
 	    GOT_COMMIT_LABEL_AUTHOR, author, author_time) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	if (asprintf(&committer_str, "%s%s %lld +0000\n",
 	    GOT_COMMIT_LABEL_COMMITTER, committer ? committer : author,
 	    committer ? committer_time : author_time)
 	    == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -343,7 +343,7 @@ got_object_commit_create(struct got_object_id **id,
 	    + strlen(author_str) + strlen(committer_str) + 2 + strlen(logmsg);
 
 	if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_COMMIT, len) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	headerlen = strlen(header) + 1;
@@ -351,7 +351,7 @@ got_object_commit_create(struct got_object_id **id,
 
 	commitfile = got_opentemp();
 	if (commitfile == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 
@@ -366,7 +366,7 @@ got_object_commit_create(struct got_object_id **id,
 		goto done;
 	if (asprintf(&tree_str, "%s%s\n", GOT_COMMIT_LABEL_TREE, id_str)
 	    == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	len = strlen(tree_str);
@@ -387,7 +387,7 @@ got_object_commit_create(struct got_object_id **id,
 			goto done;
 		if (asprintf(&parent_str, "%s%s\n", GOT_COMMIT_LABEL_PARENT,
 		    id_str) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 		len = strlen(parent_str);
@@ -441,13 +441,13 @@ got_object_commit_create(struct got_object_id **id,
 
 	*id = malloc(sizeof(**id));
 	if (*id == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		goto done;
 	}
 	SHA1Final((*id)->sha1, &sha1_ctx);
 
 	if (fflush(commitfile) != 0) {
-		err = got_error_prefix_errno("fflush");
+		err = got_error_from_errno("fflush");
 		goto done;
 	}
 	rewind(commitfile);
@@ -459,7 +459,7 @@ done:
 	free(author_str);
 	free(committer_str);
 	if (commitfile && fclose(commitfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
 		*id = NULL;
blob - 70eab62f6e930e3ef292944cbc8c3dc8cb09f48f
blob + 527383c259fb8d8e90ecf8f6b8efd21fd94a4327
--- lib/object_idset.c
+++ lib/object_idset.c
@@ -97,7 +97,7 @@ got_object_idset_add(struct got_object_idset *set, str
 
 	new = malloc(sizeof(*new));
 	if (new == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	memcpy(&new->id, id, sizeof(new->id));
 	new->data = data;
blob - 33ea7acf54a5d270b0227cb62feb35f838a4f8be
blob + 9559b3499f03914992d9378fd06de60541916cdd
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -68,11 +68,11 @@ got_object_qid_alloc_partial(struct got_object_qid **q
 
 	*qid = malloc(sizeof(**qid));
 	if (*qid == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	(*qid)->id = malloc(sizeof(*((*qid)->id)));
 	if ((*qid)->id == NULL) {
-		err = got_error_prefix_errno("malloc");
+		err = got_error_from_errno("malloc");
 		got_object_qid_free(*qid);
 		*qid = NULL;
 		return err;
@@ -88,7 +88,7 @@ got_object_id_str(char **outbuf, struct got_object_id 
 
 	*outbuf = malloc(len);
 	if (*outbuf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
 		free(*outbuf);
@@ -175,7 +175,7 @@ got_object_parse_header(struct got_object **obj, char 
 
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	(*obj)->type = type;
 	(*obj)->hdrlen = hdrlen;
 	(*obj)->size = size;
@@ -196,7 +196,7 @@ got_object_read_header(struct got_object **obj, int fd
 
 	buf = malloc(zbsize);
 	if (buf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	err = got_inflate_init(&zb, buf, zbsize);
 	if (err)
@@ -215,7 +215,7 @@ got_object_read_header(struct got_object **obj, int fd
 			nbuf++;
 			newbuf = recallocarray(buf, nbuf - 1, nbuf, zbsize);
 			if (newbuf == NULL) {
-				err = got_error_prefix_errno("recallocarray");
+				err = got_error_from_errno("recallocarray");
 				goto done;
 			}
 			buf = newbuf;
@@ -314,7 +314,7 @@ parse_commit_time(time_t *time, time_t *gmtoff, char *
 		return got_error(GOT_ERR_BAD_OBJ_DATA);
 	tzstr = strdup(space + 1);
 	if (tzstr == NULL)
-		return got_error_prefix_errno("strdup");
+		return got_error_from_errno("strdup");
 	err = parse_gmtoff(gmtoff, tzstr);
 	free(tzstr);
 	if (err)
@@ -434,7 +434,7 @@ got_object_parse_commit(struct got_commit_object **com
 
 	*commit = got_object_commit_alloc_partial();
 	if (*commit == NULL)
-		return got_error_prefix_errno("got_object_commit_alloc_partial");
+		return got_error_from_errno("got_object_commit_alloc_partial");
 
 	label_len = strlen(GOT_COMMIT_LABEL_TREE);
 	if (strncmp(s, GOT_COMMIT_LABEL_TREE, label_len) == 0) {
@@ -495,7 +495,7 @@ got_object_parse_commit(struct got_commit_object **com
 			goto done;
 		(*commit)->author = strdup(s);
 		if ((*commit)->author == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		s += slen + 1;
@@ -526,7 +526,7 @@ got_object_parse_commit(struct got_commit_object **com
 			goto done;
 		(*commit)->committer = strdup(s);
 		if ((*commit)->committer == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		s += slen + 1;
@@ -535,7 +535,7 @@ got_object_parse_commit(struct got_commit_object **com
 
 	(*commit)->logmsg = strndup(s, remain);
 	if ((*commit)->logmsg == NULL) {
-		err = got_error_prefix_errno("strndup");
+		err = got_error_from_errno("strndup");
 		goto done;
 	}
 done:
@@ -605,7 +605,7 @@ parse_tree_entry(struct got_tree_entry **te, size_t *e
 
 	*te = got_alloc_tree_entry_partial();
 	if (*te == NULL)
-		return got_error_prefix_errno("got_alloc_tree_entry_partial");
+		return got_error_from_errno("got_alloc_tree_entry_partial");
 
 	*elen = strnlen(buf, maxlen) + 1;
 	if (*elen > maxlen) {
@@ -661,7 +661,7 @@ got_object_parse_tree(struct got_tree_object **tree, u
 
 	*tree = calloc(1, sizeof(**tree));
 	if (*tree == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	SIMPLEQ_INIT(&(*tree)->entries.head);
 
@@ -720,7 +720,7 @@ got_object_parse_tag(struct got_tag_object **tag, uint
 
 	*tag = calloc(1, sizeof(**tag));
 	if (*tag == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	label_len = strlen(GOT_TAG_LABEL_OBJECT);
 	if (strncmp(s, GOT_TAG_LABEL_OBJECT, label_len) == 0) {
@@ -817,7 +817,7 @@ got_object_parse_tag(struct got_tag_object **tag, uint
 		slen = strlen(s);
 		(*tag)->tag = strndup(s, slen);
 		if ((*tag)->tag == NULL) {
-			err = got_error_prefix_errno("strndup");
+			err = got_error_from_errno("strndup");
 			goto done;
 		}
 		s += slen + 1;
@@ -855,7 +855,7 @@ got_object_parse_tag(struct got_tag_object **tag, uint
 			goto done;
 		(*tag)->tagger = strdup(s);
 		if ((*tag)->tagger == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		s += slen + 1;
@@ -868,14 +868,14 @@ got_object_parse_tag(struct got_tag_object **tag, uint
 		/* Some old tags in the Linux git repo have no tagger. */
 		(*tag)->tagger = strdup("");
 		if ((*tag)->tagger == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 	}
 
 	(*tag)->tagmsg = strndup(s, remain);
 	if ((*tag)->tagmsg == NULL) {
-		err = got_error_prefix_errno("strndup");
+		err = got_error_from_errno("strndup");
 		goto done;
 	}
 done:
@@ -899,7 +899,7 @@ got_read_file_to_mem(uint8_t **outbuf, size_t *outlen,
 
 	buf = malloc(blocksize);
 	if (buf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	remain = blocksize;
 	total = 0;
@@ -908,7 +908,7 @@ got_read_file_to_mem(uint8_t **outbuf, size_t *outlen,
 			uint8_t *newbuf;
 			newbuf = reallocarray(buf, 1, total + blocksize);
 			if (newbuf == NULL) {
-				err = got_error_prefix_errno("reallocarray");
+				err = got_error_from_errno("reallocarray");
 				goto done;
 			}
 			buf = newbuf;
blob - a57145d2b038aab6670b164672f242bdd3fc598e
blob + 212a9365a8970d664fb888047b028d3bb46a7391
--- lib/opentemp.c
+++ lib/opentemp.c
@@ -66,12 +66,12 @@ got_opentemp_named(char **path, FILE **outfile, const 
 
 	if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
 		*path = NULL;
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 	}
 
 	fd = mkstemp(*path);
 	if (fd == -1) {
-		err = got_error_prefix_errno("mkstemp");
+		err = got_error_from_errno("mkstemp");
 		free(*path);
 		*path = NULL;
 		return err;
@@ -79,7 +79,7 @@ got_opentemp_named(char **path, FILE **outfile, const 
 
 	*outfile = fdopen(fd, "w+");
 	if (*outfile == NULL) {
-		err = got_error_prefix_errno("fdopen");
+		err = got_error_from_errno("fdopen");
 		free(*path);
 		*path = NULL;
 	}
@@ -97,12 +97,12 @@ got_opentemp_named_fd(char **path, int *outfd, const c
 
 	if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
 		*path = NULL;
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 	}
 
 	fd = mkstemp(*path);
 	if (fd == -1) {
-		err = got_error_prefix_errno("mkstemp");
+		err = got_error_from_errno("mkstemp");
 		free(*path);
 		*path = NULL;
 		return err;
blob - 8e7bca71c1527510b415e58c7e90e5c655811ca6
blob + 9bf9884ba4fea911efb366206d1c811d1b35829e
--- lib/pack.c
+++ lib/pack.c
@@ -91,16 +91,16 @@ got_pack_get_packfile_size(size_t *size, const char *p
 			return got_error(GOT_ERR_BAD_PATH);
 		*dot = '\0';
 		if (asprintf(&path_pack, "%s.pack", base_path) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 
 		if (stat(path_pack, &sb) != 0)
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 		free(path_pack);
 		if (err)
 			return err;
 	} else if (strcmp(dot, GOT_PACKFILE_SUFFIX) == 0) {
 		if (stat(path, &sb) != 0)
-			return got_error_prefix_errno2("stat", path);
+			return got_error_from_errno2("stat", path);
 	} else
 		return got_error(GOT_ERR_BAD_PATH);
 
@@ -133,12 +133,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->magic = malloc(sizeof(*h->magic));
 		if (h->magic == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->magic, sizeof(*h->magic));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != sizeof(*h->magic)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -163,12 +163,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->version = malloc(sizeof(*h->version));
 		if (h->version == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->version, sizeof(*h->version));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != sizeof(*h->version)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -195,12 +195,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->fanout_table = malloc(len_fanout);
 		if (h->fanout_table == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->fanout_table, len_fanout);
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != len_fanout) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -231,7 +231,7 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 		}
 		n = read(p->fd, h->sorted_ids, len_ids);
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != len_ids) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -251,12 +251,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->crc32 = malloc(nobj * sizeof(*h->crc32));
 		if (h->crc32 == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->crc32, nobj * sizeof(*h->crc32));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != nobj * sizeof(*h->crc32)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -276,12 +276,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->offsets = malloc(nobj * sizeof(*h->offsets));
 		if (h->offsets == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->offsets, nobj * sizeof(*h->offsets));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != nobj * sizeof(*h->offsets)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -306,13 +306,13 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	else {
 		h->offsets = malloc(nobj * sizeof(*h->large_offsets));
 		if (h->offsets == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->large_offsets,
 		    nobj * sizeof(*h->large_offsets));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != nobj * sizeof(*h->large_offsets)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -335,12 +335,12 @@ checksum:
 	else {
 		h->trailer = malloc(sizeof(*h->trailer));
 		if (h->trailer == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			goto done;
 		}
 		n = read(p->fd, h->trailer, sizeof(*h->trailer));
 		if (n < 0)
-			err = got_error_prefix_errno("read");
+			err = got_error_from_errno("read");
 		else if (n != sizeof(*h->trailer)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
@@ -367,11 +367,11 @@ got_packidx_open(struct got_packidx **packidx, const c
 
 	p = calloc(1, sizeof(*p));
 	if (p == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	p->fd = open(path, O_RDONLY | O_NOFOLLOW);
 	if (p->fd == -1)
-		return got_error_prefix_errno2("open", path);
+		return got_error_from_errno2("open", path);
 
 	err = got_pack_get_packfile_size(&p->len, path);
 	if (err) {
@@ -388,7 +388,7 @@ got_packidx_open(struct got_packidx **packidx, const c
 
 	p->path_packidx = strdup(path);
 	if (p->path_packidx == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -396,7 +396,7 @@ got_packidx_open(struct got_packidx **packidx, const c
 	p->map = mmap(NULL, p->len, PROT_READ, MAP_PRIVATE, p->fd, 0);
 	if (p->map == MAP_FAILED) {
 		if (errno != ENOMEM) {
-			err = got_error_prefix_errno("mmap");
+			err = got_error_from_errno("mmap");
 			goto done;
 		}
 		p->map = NULL; /* fall back to read(2) */
@@ -421,7 +421,7 @@ got_packidx_close(struct got_packidx *packidx)
 	free(packidx->path_packidx);
 	if (packidx->map) {
 		if (munmap(packidx->map, packidx->len) == -1)
-			err = got_error_prefix_errno("munmap");
+			err = got_error_from_errno("munmap");
 	} else {
 		free(packidx->hdr.magic);
 		free(packidx->hdr.version);
@@ -433,7 +433,7 @@ got_packidx_close(struct got_packidx *packidx)
 		free(packidx->hdr.trailer);
 	}
 	if (close(packidx->fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	free(packidx);
 
 	return err;
@@ -497,7 +497,7 @@ got_pack_stop_privsep_child(struct got_pack *pack)
 		return err;
 	err = got_privsep_wait_for_child(pack->privsep_child->pid);
 	if (close(pack->privsep_child->imsg_fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	free(pack->privsep_child);
 	pack->privsep_child = NULL;
 	return err;
@@ -510,9 +510,9 @@ got_pack_close(struct got_pack *pack)
 
 	err = got_pack_stop_privsep_child(pack);
 	if (pack->map && munmap(pack->map, pack->filesize) == -1 && !err)
-		err = got_error_prefix_errno("munmap");
+		err = got_error_from_errno("munmap");
 	if (pack->fd != -1 && close(pack->fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	pack->fd = -1;
 	free(pack->path_packfile);
 	pack->path_packfile = NULL;
@@ -540,7 +540,7 @@ parse_object_type_and_size(uint8_t *type, uint64_t *si
 		mapoff = (size_t)offset;
 	} else {
 		if (lseek(pack->fd, offset, SEEK_SET) == -1)
-			return got_error_prefix_errno("lseek");
+			return got_error_from_errno("lseek");
 	}
 
 	do {
@@ -554,7 +554,7 @@ parse_object_type_and_size(uint8_t *type, uint64_t *si
 		} else {
 			ssize_t n = read(pack->fd, &sizeN, sizeof(sizeN));
 			if (n < 0)
-				return got_error_prefix_errno("read");
+				return got_error_from_errno("read");
 			if (n != sizeof(sizeN))
 				return got_error(GOT_ERR_BAD_PACKFILE);
 		}
@@ -582,11 +582,11 @@ open_plain_object(struct got_object **obj, const char 
 {
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*obj)->path_packfile = strdup(path_packfile);
 	if ((*obj)->path_packfile == NULL) {
-		const struct got_error *err = got_error_prefix_errno("strdup");
+		const struct got_error *err = got_error_from_errno("strdup");
 		free(*obj);
 		*obj = NULL;
 		return err;
@@ -628,7 +628,7 @@ parse_negative_offset(int64_t *offset, size_t *len, st
 			ssize_t n;
 			n = read(pack->fd, &offN, sizeof(offN));
 			if (n < 0)
-				return got_error_prefix_errno("read");
+				return got_error_from_errno("read");
 			if (n != sizeof(offN))
 				return got_error(GOT_ERR_BAD_PACKFILE);
 		}
@@ -687,7 +687,7 @@ add_delta(struct got_delta_chain *deltas, off_t delta_
 	    delta_data_offset, delta_buf,
 	    delta_len);
 	if (delta == NULL)
-		return got_error_prefix_errno("got_delta_open");
+		return got_error_from_errno("got_delta_open");
 	/* delta is freed in got_object_close() */
 	deltas->nentries++;
 	SIMPLEQ_INSERT_HEAD(&deltas->entries, delta, entry);
@@ -721,7 +721,7 @@ resolve_offset_delta(struct got_delta_chain *deltas,
 	if (pack->map == NULL) {
 		delta_data_offset = lseek(pack->fd, 0, SEEK_CUR);
 		if (delta_data_offset == -1)
-			return got_error_prefix_errno("lseek");
+			return got_error_from_errno("lseek");
 	}
 
 	if (pack->map) {
@@ -786,7 +786,7 @@ resolve_ref_delta(struct got_delta_chain *deltas, stru
 	if (pack->map == NULL) {
 		delta_data_offset = lseek(pack->fd, 0, SEEK_CUR);
 		if (delta_data_offset == -1)
-			return got_error_prefix_errno("lseek");
+			return got_error_from_errno("lseek");
 	}
 
 	if (pack->map) {
@@ -800,7 +800,7 @@ resolve_ref_delta(struct got_delta_chain *deltas, stru
 	} else {
 		ssize_t n = read(pack->fd, &id, sizeof(id));
 		if (n < 0)
-			return got_error_prefix_errno("read");
+			return got_error_from_errno("read");
 		if (n != sizeof(id))
 			return got_error(GOT_ERR_BAD_PACKFILE);
 		err = got_inflate_to_mem_fd(&delta_buf, &delta_len, pack->fd);
@@ -888,7 +888,7 @@ open_delta_object(struct got_object **obj, struct got_
 
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*obj)->flags = 0;
 	(*obj)->hdrlen = 0;
@@ -898,7 +898,7 @@ open_delta_object(struct got_object **obj, struct got_
 
 	(*obj)->path_packfile = strdup(pack->path_packfile);
 	if ((*obj)->path_packfile == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	(*obj)->flags |= GOT_OBJ_FLAG_PACKED;
@@ -1026,7 +1026,7 @@ dump_delta_chain_to_file(size_t *result_size, struct g
 	if (max_size < GOT_DELTA_RESULT_SIZE_CACHED_MAX) {
 		accum_buf = malloc(max_size);
 		if (accum_buf == NULL)
-			return got_error_prefix_errno("malloc");
+			return got_error_from_errno("malloc");
 		base_file = NULL;
 		accum_file = NULL;
 	}
@@ -1054,7 +1054,7 @@ dump_delta_chain_to_file(size_t *result_size, struct g
 			if (pack->map == NULL) {
 				if (lseek(pack->fd, delta_data_offset, SEEK_SET)
 				    == -1) {
-					err = got_error_prefix_errno("lseek");
+					err = got_error_from_errno("lseek");
 					goto done;
 				}
 			}
@@ -1114,7 +1114,7 @@ dump_delta_chain_to_file(size_t *result_size, struct g
 					uint8_t *p;
 					p = reallocarray(base_buf, 1, max_size);
 					if (p == NULL) {
-						err = got_error_prefix_errno(
+						err = got_error_from_errno(
 						    "reallocarray");
 						goto done;
 					}
@@ -1169,7 +1169,7 @@ dump_delta_chain_to_mem(uint8_t **outbuf, size_t *outl
 		return err;
 	accum_buf = malloc(max_size);
 	if (accum_buf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	/* Deltas are ordered in ascending order. */
 	SIMPLEQ_FOREACH(delta, &deltas->entries, entry) {
@@ -1198,7 +1198,7 @@ dump_delta_chain_to_mem(uint8_t **outbuf, size_t *outl
 			} else {
 				if (lseek(pack->fd, delta_data_offset, SEEK_SET)
 				    == -1) {
-					err = got_error_prefix_errno("lseek");
+					err = got_error_from_errno("lseek");
 					goto done;
 				}
 				err = got_inflate_to_mem_fd(&base_buf,
@@ -1229,7 +1229,7 @@ dump_delta_chain_to_mem(uint8_t **outbuf, size_t *outl
 				uint8_t *p;
 				p = reallocarray(base_buf, 1, max_size);
 				if (p == NULL) {
-					err = got_error_prefix_errno(
+					err = got_error_from_errno(
 					    "reallocarray");
 					goto done;
 				}
@@ -1273,7 +1273,7 @@ got_packfile_extract_object(struct got_pack *pack, str
 			    mapoff, pack->filesize - mapoff, outfile);
 		} else {
 			if (lseek(pack->fd, obj->pack_offset, SEEK_SET) == -1)
-				return got_error_prefix_errno("lseek");
+				return got_error_from_errno("lseek");
 			err = got_inflate_to_file_fd(&obj->size, pack->fd,
 			    outfile);
 		}
@@ -1302,7 +1302,7 @@ got_packfile_extract_object_to_mem(uint8_t **buf, size
 			    mapoff, pack->filesize - mapoff);
 		} else {
 			if (lseek(pack->fd, obj->pack_offset, SEEK_SET) == -1)
-				return got_error_prefix_errno("lseek");
+				return got_error_from_errno("lseek");
 			err = got_inflate_to_mem_fd(buf, len, pack->fd);
 		}
 	} else
blob - 33840a4b76f90e86e70a5a781d76d2396a2c448b
blob + 90f647ae849b1cdf8f1170cbf329f13755004def
--- lib/path.c
+++ lib/path.c
@@ -137,9 +137,9 @@ got_path_skip_common_ancestor(char **child, const char
 	bufsize = len - len_parent + 1;
 	*child = malloc(bufsize);
 	if (*child == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 	if (strlcpy(*child, abspath + len_parent, bufsize) >= bufsize) {
-		err = got_error_prefix_errno("strlcpy");
+		err = got_error_from_errno("strlcpy");
 		free(*child);
 		*child = NULL;
 		return err;
@@ -236,7 +236,7 @@ got_pathlist_insert(struct got_pathlist_entry **insert
 
 	new = malloc(sizeof(*new));
 	if (new == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 	new->path = path;
 	new->data = data;
 
@@ -295,11 +295,11 @@ make_parent_dirs(const char *abspath)
 			if (err)
 				goto done;
 			if (mkdir(parent, GOT_DEFAULT_DIR_MODE) == -1) {
-				err = got_error_prefix_errno2("mkdir", parent);
+				err = got_error_from_errno2("mkdir", parent);
 				goto done;
 			}
 		} else
-			err = got_error_prefix_errno2("mkdir", parent);
+			err = got_error_from_errno2("mkdir", parent);
 	}
 done:
 	free(parent);
@@ -317,9 +317,9 @@ got_path_mkdir(const char *abspath)
 			if (err)
 				goto done;
 			if (mkdir(abspath, GOT_DEFAULT_DIR_MODE) == -1)
-				err = got_error_prefix_errno2("mkdir", abspath);
+				err = got_error_from_errno2("mkdir", abspath);
 		} else
-			err = got_error_prefix_errno2("mkdir", abspath);
+			err = got_error_from_errno2("mkdir", abspath);
 	}
 
 done:
@@ -357,14 +357,14 @@ got_path_dirname(char **parent, const char *path)
 
 	p = dirname(path);
 	if (p == NULL)
-		return got_error_prefix_errno2("dirname", path);
+		return got_error_from_errno2("dirname", path);
 
 	if (p[0] == '.' && p[1] == '\0')
 		return got_error(GOT_ERR_BAD_PATH);
 
 	*parent = strdup(p);
 	if (*parent == NULL)
-		return got_error_prefix_errno("strdup");
+		return got_error_from_errno("strdup");
 
 	return NULL;
 }
blob - 1601edde20cb79ee3d12560e1c0a35b354af7d2c
blob + df3fdff63112138a8d1e5e73ee27f1a8d8d412ac
--- lib/privsep.c
+++ lib/privsep.c
@@ -57,11 +57,11 @@ poll_fd(int fd, int events, int timeout)
 
 	n = poll(pfd, 1, timeout);
 	if (n == -1)
-		return got_error_prefix_errno("poll");
+		return got_error_from_errno("poll");
 	if (n == 0)
 		return got_error(GOT_ERR_TIMEOUT);
 	if (pfd[0].revents & (POLLERR | POLLNVAL))
-		return got_error_prefix_errno("poll error");
+		return got_error_from_errno("poll error");
 	if (pfd[0].revents & (events | POLLHUP))
 		return NULL;
 
@@ -96,7 +96,7 @@ got_privsep_wait_for_child(pid_t pid)
 	int child_status;
 
 	if (waitpid(pid, &child_status, 0) == -1)
-		return got_error_prefix_errno("waitpid");
+		return got_error_from_errno("waitpid");
 
 	if (!WIFEXITED(child_status))
 		return got_error(GOT_ERR_PRIVSEP_DIED);
@@ -135,7 +135,7 @@ got_privsep_recv_imsg(struct imsg *imsg, struct imsgbu
 
 	n = imsg_get(ibuf, imsg);
 	if (n == -1)
-		return got_error_prefix_errno("imsg_get");
+		return got_error_from_errno("imsg_get");
 
 	while (n == 0) {
 		err = read_imsg(ibuf);
@@ -200,7 +200,7 @@ flush_imsg(struct imsgbuf *ibuf)
 		return err;
 
 	if (imsg_flush(ibuf) == -1)
-		return got_error_prefix_errno("imsg_flush");
+		return got_error_from_errno("imsg_flush");
 
 	return NULL;
 }
@@ -214,7 +214,7 @@ got_privsep_send_stop(int fd)
 	imsg_init(&ibuf, fd);
 
 	if (imsg_compose(&ibuf, GOT_IMSG_STOP, 0, 0, -1, NULL, 0) == -1)
-		return got_error_prefix_errno("imsg_compose STOP");
+		return got_error_from_errno("imsg_compose STOP");
 
 	err = flush_imsg(&ibuf);
 	imsg_clear(&ibuf);
@@ -226,7 +226,7 @@ got_privsep_send_obj_req(struct imsgbuf *ibuf, int fd)
 {
 	if (imsg_compose(ibuf, GOT_IMSG_OBJECT_REQUEST, 0, 0, fd, NULL, 0)
 	    == -1)
-		return got_error_prefix_errno("imsg_compose OBJECT_REQUEST");
+		return got_error_from_errno("imsg_compose OBJECT_REQUEST");
 
 	return flush_imsg(ibuf);
 }
@@ -251,7 +251,7 @@ got_privsep_send_commit_req(struct imsgbuf *ibuf, int 
 
 	if (imsg_compose(ibuf, GOT_IMSG_COMMIT_REQUEST, 0, 0, fd, iobjp, len)
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose COMMIT_REQUEST");
+		err = got_error_from_errno("imsg_compose COMMIT_REQUEST");
 		close(fd);
 		return err;
 	}
@@ -279,7 +279,7 @@ got_privsep_send_tree_req(struct imsgbuf *ibuf, int fd
 
 	if (imsg_compose(ibuf, GOT_IMSG_TREE_REQUEST, 0, 0, fd, iobjp, len)
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose TREE_REQUEST");
+		err = got_error_from_errno("imsg_compose TREE_REQUEST");
 		close(fd);
 		return err;
 	}
@@ -306,7 +306,7 @@ got_privsep_send_tag_req(struct imsgbuf *ibuf, int fd,
 
 	if (imsg_compose(ibuf, GOT_IMSG_TAG_REQUEST, 0, 0, fd, iobjp, len)
 	    == -1)
-		return got_error_prefix_errno("imsg_compose TAG_REQUEST");
+		return got_error_from_errno("imsg_compose TAG_REQUEST");
 
 	return flush_imsg(ibuf);
 }
@@ -331,7 +331,7 @@ got_privsep_send_blob_req(struct imsgbuf *ibuf, int in
 
 	if (imsg_compose(ibuf, GOT_IMSG_BLOB_REQUEST, 0, 0, infd, iobjp, len)
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose BLOB_REQUEST");
+		err = got_error_from_errno("imsg_compose BLOB_REQUEST");
 		close(infd);
 		return err;
 	}
@@ -346,7 +346,7 @@ got_privsep_send_blob_outfd(struct imsgbuf *ibuf, int 
 
 	if (imsg_compose(ibuf, GOT_IMSG_BLOB_OUTFD, 0, 0, outfd, NULL, 0)
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose BLOB_OUTFD");
+		err = got_error_from_errno("imsg_compose BLOB_OUTFD");
 		close(outfd);
 		return err;
 	}
@@ -361,7 +361,7 @@ got_privsep_send_tmpfd(struct imsgbuf *ibuf, int fd)
 
 	if (imsg_compose(ibuf, GOT_IMSG_TMPFD, 0, 0, fd, NULL, 0)
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose TMPFD");
+		err = got_error_from_errno("imsg_compose TMPFD");
 		close(fd);
 		return err;
 	}
@@ -386,7 +386,7 @@ got_privsep_send_obj(struct imsgbuf *ibuf, struct got_
 
 	if (imsg_compose(ibuf, GOT_IMSG_OBJECT, 0, 0, -1, &iobj, sizeof(iobj))
 	    == -1)
-		return got_error_prefix_errno("imsg_compose OBJECT");
+		return got_error_from_errno("imsg_compose OBJECT");
 
 	return flush_imsg(ibuf);
 }
@@ -405,7 +405,7 @@ got_privsep_get_imsg_obj(struct got_object **obj, stru
 
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	memcpy((*obj)->id.sha1, iobj->id, SHA1_DIGEST_LENGTH);
 	(*obj)->type = iobj->type;
@@ -466,7 +466,7 @@ send_commit_logmsg(struct imsgbuf *ibuf, struct got_co
 
 		if (imsg_compose(ibuf, GOT_IMSG_COMMIT_LOGMSG, 0, 0, -1,
 		    commit->logmsg + offset, n) == -1) {
-			err = got_error_prefix_errno("imsg_compose "
+			err = got_error_from_errno("imsg_compose "
 			    "COMMIT_LOGMSG");
 			break;
 		}
@@ -499,7 +499,7 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct g
 
 	buf = malloc(total);
 	if (buf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	icommit = (struct got_imsg_commit_object *)buf;
 	memcpy(icommit->tree_id, commit->tree_id->sha1,
@@ -524,7 +524,7 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct g
 	}
 
 	if (imsg_compose(ibuf, GOT_IMSG_COMMIT, 0, 0, -1, buf, len) == -1) {
-		err = got_error_prefix_errno("imsg_compose COMMIT");
+		err = got_error_from_errno("imsg_compose COMMIT");
 		goto done;
 	}
 
@@ -582,7 +582,7 @@ got_privsep_recv_commit(struct got_commit_object **com
 
 		*commit = got_object_commit_alloc_partial();
 		if (*commit == NULL) {
-			err = got_error_prefix_errno(
+			err = got_error_from_errno(
 			    "got_object_commit_alloc_partial");
 			break;
 		}
@@ -597,13 +597,13 @@ got_privsep_recv_commit(struct got_commit_object **com
 		if (icommit->author_len == 0) {
 			(*commit)->author = strdup("");
 			if ((*commit)->author == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
 			(*commit)->author = malloc(icommit->author_len + 1);
 			if ((*commit)->author == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			memcpy((*commit)->author, imsg.data + len,
@@ -615,14 +615,14 @@ got_privsep_recv_commit(struct got_commit_object **com
 		if (icommit->committer_len == 0) {
 			(*commit)->committer = strdup("");
 			if ((*commit)->committer == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
 			(*commit)->committer =
 			    malloc(icommit->committer_len + 1);
 			if ((*commit)->committer == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			memcpy((*commit)->committer, imsg.data + len,
@@ -634,7 +634,7 @@ got_privsep_recv_commit(struct got_commit_object **com
 		if (icommit->logmsg_len == 0) {
 			(*commit)->logmsg = strdup("");
 			if ((*commit)->logmsg == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
@@ -642,7 +642,7 @@ got_privsep_recv_commit(struct got_commit_object **com
 
 			(*commit)->logmsg = malloc(icommit->logmsg_len + 1);
 			if ((*commit)->logmsg == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			while (remain > 0) {
@@ -700,7 +700,7 @@ got_privsep_send_tree(struct imsgbuf *ibuf, struct got
 	itree.nentries = tree->entries.nentries;
 	if (imsg_compose(ibuf, GOT_IMSG_TREE, 0, 0, -1, &itree, sizeof(itree))
 	    == -1)
-		return got_error_prefix_errno("imsg_compose TREE");
+		return got_error_from_errno("imsg_compose TREE");
 
 	totlen = sizeof(itree);
 	nimsg = 1;
@@ -722,7 +722,7 @@ got_privsep_send_tree(struct imsgbuf *ibuf, struct got
 
 		buf = malloc(len);
 		if (buf == NULL)
-			return got_error_prefix_errno("malloc");
+			return got_error_from_errno("malloc");
 
 		ite = (struct got_imsg_tree_entry *)buf;
 		memcpy(ite->id, te->id->sha1, sizeof(ite->id));
@@ -731,7 +731,7 @@ got_privsep_send_tree(struct imsgbuf *ibuf, struct got
 
 		if (imsg_compose(ibuf, GOT_IMSG_TREE_ENTRY, 0, 0, -1,
 		    buf, len) == -1)
-			err = got_error_prefix_errno("imsg_compose TREE_ENTRY");
+			err = got_error_from_errno("imsg_compose TREE_ENTRY");
 		free(buf);
 		if (err)
 			return err;
@@ -793,7 +793,7 @@ get_more:
 			itree = imsg.data;
 			*tree = malloc(sizeof(**tree));
 			if (*tree == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			(*tree)->entries.nentries = itree->nentries;
@@ -821,14 +821,14 @@ get_more:
 
 			te = got_alloc_tree_entry_partial();
 			if (te == NULL) {
-				err = got_error_prefix_errno(
+				err = got_error_from_errno(
 				    "got_alloc_tree_entry_partial");
 				break;
 			}
 			te->name = malloc(datalen + 1);
 			if (te->name == NULL) {
 				free(te);
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			memcpy(te->name, imsg.data + sizeof(*ite), datalen);
@@ -874,21 +874,21 @@ got_privsep_send_blob(struct imsgbuf *ibuf, size_t siz
 
 		buf = malloc(sizeof(iblob) + size);
 		if (buf == NULL)
-			return got_error_prefix_errno("malloc");
+			return got_error_from_errno("malloc");
 
 		memcpy(buf, &iblob, sizeof(iblob));
 		memcpy(buf + sizeof(iblob), data, size);
 		if (imsg_compose(ibuf, GOT_IMSG_BLOB, 0, 0, -1, buf,
 		   sizeof(iblob) + size) == -1) {
 			free(buf);
-			return got_error_prefix_errno("imsg_compose BLOB");
+			return got_error_from_errno("imsg_compose BLOB");
 		}
 		free(buf);
 	} else {
 		/* Data has already been written to file descriptor. */
 		if (imsg_compose(ibuf, GOT_IMSG_BLOB, 0, 0, -1, &iblob,
 		    sizeof(iblob)) == -1)
-			return got_error_prefix_errno("imsg_compose BLOB");
+			return got_error_from_errno("imsg_compose BLOB");
 	}
 
 
@@ -934,7 +934,7 @@ got_privsep_recv_blob(uint8_t **outbuf, size_t *size, 
 
 		*outbuf = malloc(*size);
 		if (*outbuf == NULL) {
-			err = got_error_prefix_errno("malloc");
+			err = got_error_from_errno("malloc");
 			break;
 		}
 		memcpy(*outbuf, imsg.data + sizeof(*iblob), *size);
@@ -962,7 +962,7 @@ send_tagmsg(struct imsgbuf *ibuf, struct got_tag_objec
 
 		if (imsg_compose(ibuf, GOT_IMSG_TAG_TAGMSG, 0, 0, -1,
 		    tag->tagmsg + offset, n) == -1) {
-			err = got_error_prefix_errno("imsg_compose TAG_TAGMSG");
+			err = got_error_from_errno("imsg_compose TAG_TAGMSG");
 			break;
 		}
 
@@ -992,7 +992,7 @@ got_privsep_send_tag(struct imsgbuf *ibuf, struct got_
 
 	buf = malloc(total);
 	if (buf == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	itag = (struct got_imsg_tag_object *)buf;
 	memcpy(itag->id, tag->id.sha1, sizeof(itag->id));
@@ -1010,7 +1010,7 @@ got_privsep_send_tag(struct imsgbuf *ibuf, struct got_
 	len += tagger_len;
 
 	if (imsg_compose(ibuf, GOT_IMSG_TAG, 0, 0, -1, buf, len) == -1) {
-		err = got_error_prefix_errno("imsg_compose TAG");
+		err = got_error_from_errno("imsg_compose TAG");
 		goto done;
 	}
 
@@ -1062,7 +1062,7 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 
 		*tag = calloc(1, sizeof(**tag));
 		if (*tag == NULL) {
-			err = got_error_prefix_errno("calloc");
+			err = got_error_from_errno("calloc");
 			break;
 		}
 
@@ -1071,13 +1071,13 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 		if (itag->tag_len == 0) {
 			(*tag)->tag = strdup("");
 			if ((*tag)->tag == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
 			(*tag)->tag = malloc(itag->tag_len + 1);
 			if ((*tag)->tag == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			memcpy((*tag)->tag, imsg.data + len,
@@ -1093,13 +1093,13 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 		if (itag->tagger_len == 0) {
 			(*tag)->tagger = strdup("");
 			if ((*tag)->tagger == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
 			(*tag)->tagger = malloc(itag->tagger_len + 1);
 			if ((*tag)->tagger == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			memcpy((*tag)->tagger, imsg.data + len,
@@ -1111,7 +1111,7 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 		if (itag->tagmsg_len == 0) {
 			(*tag)->tagmsg = strdup("");
 			if ((*tag)->tagmsg == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				break;
 			}
 		} else {
@@ -1119,7 +1119,7 @@ got_privsep_recv_tag(struct got_tag_object **tag, stru
 
 			(*tag)->tagmsg = malloc(itag->tagmsg_len + 1);
 			if ((*tag)->tagmsg == NULL) {
-				err = got_error_prefix_errno("malloc");
+				err = got_error_from_errno("malloc");
 				break;
 			}
 			while (remain > 0) {
@@ -1166,11 +1166,11 @@ got_privsep_init_pack_child(struct imsgbuf *ibuf, stru
 	ipackidx.len = packidx->len;
 	fd = dup(packidx->fd);
 	if (fd == -1)
-		return got_error_prefix_errno("dup");
+		return got_error_from_errno("dup");
 
 	if (imsg_compose(ibuf, GOT_IMSG_PACKIDX, 0, 0, fd, &ipackidx,
 	    sizeof(ipackidx)) == -1) {
-		err = got_error_prefix_errno("imsg_compose PACKIDX");
+		err = got_error_from_errno("imsg_compose PACKIDX");
 		close(fd);
 		return err;
 	}
@@ -1182,11 +1182,11 @@ got_privsep_init_pack_child(struct imsgbuf *ibuf, stru
 
 	fd = dup(pack->fd);
 	if (fd == -1)
-		return got_error_prefix_errno("dup");
+		return got_error_from_errno("dup");
 
 	if (imsg_compose(ibuf, GOT_IMSG_PACK, 0, 0, fd, &ipack, sizeof(ipack))
 	    == -1) {
-		err = got_error_prefix_errno("imsg_compose PACK");
+		err = got_error_from_errno("imsg_compose PACK");
 		close(fd);
 		return err;
 	}
@@ -1205,7 +1205,7 @@ got_privsep_send_packed_obj_req(struct imsgbuf *ibuf, 
 
 	if (imsg_compose(ibuf, GOT_IMSG_PACKED_OBJECT_REQUEST, 0, 0, -1,
 	    &iobj, sizeof(iobj)) == -1)
-		return got_error_prefix_errno("imsg_compose "
+		return got_error_from_errno("imsg_compose "
 		    "PACKED_OBJECT_REQUEST");
 
 	return flush_imsg(ibuf);
@@ -1220,7 +1220,7 @@ got_privsep_unveil_exec_helpers(void)
 	    unveil(GOT_PATH_PROG_READ_TREE, "x") != 0 ||
 	    unveil(GOT_PATH_PROG_READ_BLOB, "x") != 0 ||
 	    unveil(GOT_PATH_PROG_READ_TAG, "x") != 0)
-		return got_error_prefix_errno("unveil");
+		return got_error_from_errno("unveil");
 
 	return NULL;
 }
blob - ff09bbce69de69bf78d62bc157725924fc2ff292
blob + c2d7153928e0760cd9d259ef3aa6621137d0d05f
--- lib/reference.c
+++ lib/reference.c
@@ -92,13 +92,13 @@ alloc_ref(struct got_reference **ref, const char *name
 
 	*ref = calloc(1, sizeof(**ref));
 	if (*ref == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	memcpy((*ref)->ref.ref.sha1, id->sha1, sizeof((*ref)->ref.ref.sha1));
 	(*ref)->flags = flags;
 	(*ref)->ref.ref.name = strdup(name);
 	if ((*ref)->ref.ref.name == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		got_ref_close(*ref);
 		*ref = NULL;
 	}
@@ -113,18 +113,18 @@ alloc_symref(struct got_reference **ref, const char *n
 
 	*ref = calloc(1, sizeof(**ref));
 	if (*ref == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*ref)->flags = GOT_REF_IS_SYMBOLIC | flags;
 	(*ref)->ref.symref.name = strdup(name);
 	if ((*ref)->ref.symref.name == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		got_ref_close(*ref);
 		*ref = NULL;
 	}
 	(*ref)->ref.symref.ref = strdup(target_ref);
 	if ((*ref)->ref.symref.ref == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		got_ref_close(*ref);
 		*ref = NULL;
 	}
@@ -202,7 +202,7 @@ parse_ref_file(struct got_reference **ref, const char 
 done:
 	free(line);
 	if (fclose(f) != 0 && err == NULL) {
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 		if (*ref) {
 			if (lock)
 				got_ref_unlock(*ref);
@@ -348,7 +348,7 @@ open_packed_ref(struct got_reference **ref, FILE *f, c
 			if (!ref_is_absolute &&
 			    asprintf(&abs_refname, "refs/%s/%s", subdirs[i],
 			    refname) == -1)
-				return got_error_prefix_errno("asprintf");
+				return got_error_from_errno("asprintf");
 			err = parse_packed_ref_line(ref, abs_refname, line);
 			if (!ref_is_absolute)
 				free(abs_refname);
@@ -378,23 +378,23 @@ open_ref(struct got_reference **ref, const char *path_
 
 	if (ref_is_absolute || ref_is_well_known) {
 		if (asprintf(&path, "%s/%s", path_refs, name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 		absname = (char *)name;
 	} else {
 		if (asprintf(&path, "%s/%s%s%s", path_refs, subdir,
 		    subdir[0] ? "/" : "", name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 
 		if (asprintf(&absname, "refs/%s%s%s",
 		    subdir, subdir[0] ? "/" : "", name) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 	}
 
 	normpath = got_path_normalize(path);
 	if (normpath == NULL) {
-		err = got_error_prefix_errno2("got_path_normalize", path);
+		err = got_error_from_errno2("got_path_normalize", path);
 		goto done;
 	}
 
@@ -423,7 +423,7 @@ got_ref_open(struct got_reference **ref, struct got_re
 
 	path_refs = get_refs_dir_path(repo, refname);
 	if (path_refs == NULL) {
-		err = got_error_prefix_errno2("get_refs_dir_path", refname);
+		err = got_error_from_errno2("get_refs_dir_path", refname);
 		goto done;
 	}
 
@@ -443,7 +443,7 @@ got_ref_open(struct got_reference **ref, struct got_re
 
 		packed_refs_path = got_repo_get_path_packed_refs(repo);
 		if (packed_refs_path == NULL) {
-			err = got_error_prefix_errno(
+			err = got_error_from_errno(
 			    "got_repo_get_path_packed_refs");
 			goto done;
 		}
@@ -460,7 +460,7 @@ got_ref_open(struct got_reference **ref, struct got_re
 			    refname);
 			if (!err) {
 				if (fclose(f) != 0) {
-					err = got_error_prefix_errno("fclose");
+					err = got_error_from_errno("fclose");
 					got_ref_close(*ref);
 					*ref = NULL;
 				} else
@@ -561,7 +561,7 @@ got_ref_resolve(struct got_object_id **id, struct got_
 
 	*id = calloc(1, sizeof(**id));
 	if (*id == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 	memcpy((*id)->sha1, ref->ref.ref.sha1, sizeof((*id)->sha1));
 	return NULL;
 }
@@ -614,7 +614,7 @@ insert_ref(struct got_reflist_entry **newp, struct got
 	new = malloc(sizeof(*new));
 	if (new == NULL) {
 		free(id);
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 	}
 	new->ref = ref;
 	new->id = id;
@@ -661,7 +661,7 @@ gather_on_disk_refs(struct got_reflist_head *refs, con
 	char *path_subdir;
 
 	if (asprintf(&path_subdir, "%s/%s", path_refs, subdir) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	d = opendir(path_subdir);
 	if (d == NULL)
@@ -698,7 +698,7 @@ gather_on_disk_refs(struct got_reflist_head *refs, con
 		case DT_DIR:
 			if (asprintf(&child, "%s%s%s", subdir,
 			    subdir[0] == '\0' ? "" : "/", dent->d_name) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				break;
 			}
 			err = gather_on_disk_refs(refs, path_refs, child, repo);
@@ -727,7 +727,7 @@ got_ref_list(struct got_reflist_head *refs, struct got
 	/* HEAD ref should always exist. */
 	path_refs = get_refs_dir_path(repo, GOT_REF_HEAD);
 	if (path_refs == NULL) {
-		err = got_error_prefix_errno("get_refs_dir_path");
+		err = got_error_from_errno("get_refs_dir_path");
 		goto done;
 	}
 	err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0);
@@ -743,7 +743,7 @@ got_ref_list(struct got_reflist_head *refs, struct got
 	free(path_refs);
 	path_refs = get_refs_dir_path(repo, "");
 	if (path_refs == NULL) {
-		err = got_error_prefix_errno("get_refs_dir_path");
+		err = got_error_from_errno("get_refs_dir_path");
 		goto done;
 	}
 	err = gather_on_disk_refs(refs, path_refs, "", repo);
@@ -756,7 +756,7 @@ got_ref_list(struct got_reflist_head *refs, struct got
 	 */
 	packed_refs_path = got_repo_get_path_packed_refs(repo);
 	if (packed_refs_path == NULL) {
-		err = got_error_prefix_errno("got_repo_get_path_packed_refs");
+		err = got_error_from_errno("got_repo_get_path_packed_refs");
 		goto done;
 	}
 
@@ -790,7 +790,7 @@ got_ref_list(struct got_reflist_head *refs, struct got
 done:
 	free(path_refs);
 	if (f && fclose(f) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	return err;
 }
 
@@ -835,7 +835,7 @@ got_ref_change_symref(struct got_reference *ref, char 
 
 	new_name = strdup(refname);
 	if (new_name == NULL)
-		return got_error_prefix_errno("strdup");
+		return got_error_from_errno("strdup");
 
 	free(ref->ref.symref.name);
 	ref->ref.symref.name = new_name;
@@ -855,12 +855,12 @@ got_ref_write(struct got_reference *ref, struct got_re
 
 	path_refs = get_refs_dir_path(repo, name);
 	if (path_refs == NULL) {
-		err = got_error_prefix_errno2("get_refs_dir_path", name);
+		err = got_error_from_errno2("get_refs_dir_path", name);
 		goto done;
 	}
 
 	if (asprintf(&path, "%s/%s", path_refs, name) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -911,21 +911,21 @@ got_ref_write(struct got_reference *ref, struct got_re
 
 	if (stat(path, &sb) != 0) {
 		if (errno != ENOENT) {
-			err = got_error_prefix_errno2("stat", path);
+			err = got_error_from_errno2("stat", path);
 			goto done;
 		}
 		sb.st_mode = GOT_DEFAULT_FILE_MODE;
 	}
 
 	if (rename(tmppath, path) != 0) {
-		err = got_error_prefix_errno3("rename", tmppath, path);
+		err = got_error_from_errno3("rename", tmppath, path);
 		goto done;
 	}
 	free(tmppath);
 	tmppath = NULL;
 
 	if (chmod(path, sb.st_mode) != 0) {
-		err = got_error_prefix_errno2("chmod", path);
+		err = got_error_from_errno2("chmod", path);
 		goto done;
 	}
 done:
@@ -933,13 +933,13 @@ done:
 		unlock_err = got_lockfile_unlock(lf);
 	if (f) {
 		if (fclose(f) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	free(path_refs);
 	free(path);
 	if (tmppath) {
 		if (unlink(tmppath) != 0 && err == NULL)
-			err = got_error_prefix_errno2("unlink", tmppath);
+			err = got_error_from_errno2("unlink", tmppath);
 		free(tmppath);
 	}
 	return err ? err : unlock_err;
@@ -963,7 +963,7 @@ delete_packed_ref(struct got_reference *delref, struct
 
 	packed_refs_path = got_repo_get_path_packed_refs(repo);
 	if (packed_refs_path == NULL)
-		return got_error_prefix_errno("got_repo_get_path_packed_refs");
+		return got_error_from_errno("got_repo_get_path_packed_refs");
 
 	err = got_opentemp_named(&tmppath, &tmpf, packed_refs_path);
 	if (err)
@@ -977,7 +977,7 @@ delete_packed_ref(struct got_reference *delref, struct
 
 	f = fopen(packed_refs_path, "r");
 	if (f == NULL) {
-		err = got_error_prefix_errno2("fopen", packed_refs_path);
+		err = got_error_from_errno2("fopen", packed_refs_path);
 		goto done;
 	}
 	for (;;) {
@@ -1048,13 +1048,13 @@ delete_packed_ref(struct got_reference *delref, struct
 		}
 
 		if (fflush(tmpf) != 0) {
-			err = got_error_prefix_errno("fflush");
+			err = got_error_from_errno("fflush");
 			goto done;
 		}
 
 		if (stat(packed_refs_path, &sb) != 0) {
 			if (errno != ENOENT) {
-				err = got_error_prefix_errno2("stat",
+				err = got_error_from_errno2("stat",
 				    packed_refs_path);
 				goto done;
 			}
@@ -1062,13 +1062,13 @@ delete_packed_ref(struct got_reference *delref, struct
 		}
 
 		if (rename(tmppath, packed_refs_path) != 0) {
-			err = got_error_prefix_errno3("rename", tmppath,
+			err = got_error_from_errno3("rename", tmppath,
 			    packed_refs_path);
 			goto done;
 		}
 
 		if (chmod(packed_refs_path, sb.st_mode) != 0) {
-			err = got_error_prefix_errno2("chmod",
+			err = got_error_from_errno2("chmod",
 			    packed_refs_path);
 			goto done;
 		}
@@ -1078,12 +1078,12 @@ done:
 		unlock_err = got_lockfile_unlock(lf);
 	if (f) {
 		if (fclose(f) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	if (tmpf) {
 		unlink(tmppath);
 		if (fclose(tmpf) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	free(tmppath);
 	free(packed_refs_path);
@@ -1104,12 +1104,12 @@ got_ref_delete(struct got_reference *ref, struct got_r
 
 	path_refs = get_refs_dir_path(repo, name);
 	if (path_refs == NULL) {
-		err = got_error_prefix_errno2("get_refs_dir_path", name);
+		err = got_error_from_errno2("get_refs_dir_path", name);
 		goto done;
 	}
 
 	if (asprintf(&path, "%s/%s", path_refs, name) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -1122,7 +1122,7 @@ got_ref_delete(struct got_reference *ref, struct got_r
 	/* XXX: check if old content matches our expectations? */
 
 	if (unlink(path) != 0)
-		err = got_error_prefix_errno2("unlink", path);
+		err = got_error_from_errno2("unlink", path);
 done:
 	if (ref->lf == NULL && lf)
 		unlock_err = got_lockfile_unlock(lf);
blob - ef82dcbdfbbb231f2e5911319eb6ff7952e6276d
blob + 4a2efe86fcf1cf4a1e8a7b1cac198509adfa3a8c
--- lib/repository.c
+++ lib/repository.c
@@ -267,11 +267,11 @@ open_repo(struct got_repository *repo, const char *pat
 	/* bare git repository? */
 	repo->path_git_dir = strdup(path);
 	if (repo->path_git_dir == NULL)
-		return got_error_prefix_errno("strdup");
+		return got_error_from_errno("strdup");
 	if (is_git_repo(repo)) {
 		repo->path = strdup(repo->path_git_dir);
 		if (repo->path == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		return NULL;
@@ -280,13 +280,13 @@ open_repo(struct got_repository *repo, const char *pat
 	/* git repository with working tree? */
 	free(repo->path_git_dir);
 	if (asprintf(&repo->path_git_dir, "%s/%s", path, GOT_GIT_DIR) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	if (is_git_repo(repo)) {
 		repo->path = strdup(path);
 		if (repo->path == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		return NULL;
@@ -322,7 +322,7 @@ got_repo_open(struct got_repository **repop, const cha
 
 	repo = calloc(1, sizeof(*repo));
 	if (repo == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -371,7 +371,7 @@ got_repo_open(struct got_repository **repop, const cha
 		}
 		path = dirname(path);
 		if (path == NULL)
-			err = got_error_prefix_errno2("dirname", path);
+			err = got_error_from_errno2("dirname", path);
 	} while (path);
 done:
 	if (err)
@@ -421,7 +421,7 @@ got_repo_close(struct got_repository *repo)
 			err = child_err;
 		if (close(repo->privsep_children[i].imsg_fd) != 0 &&
 		    err == NULL)
-			err = got_error_prefix_errno("close");
+			err = got_error_from_errno("close");
 	}
 	free(repo);
 
@@ -441,11 +441,11 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL)
-		return got_error_prefix_errno("getcwd");
+		return got_error_from_errno("getcwd");
 
 	canonpath = strdup(input_path);
 	if (canonpath == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	err = got_canonpath(input_path, canonpath, strlen(canonpath) + 1);
@@ -457,7 +457,7 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 	if (!check_disk) {
 		path = strdup(canonpath);
 		if (path == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else {
@@ -466,7 +466,7 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 		path = realpath(canonpath, NULL);
 		if (path == NULL) {
 			if (errno != ENOENT) {
-				err = got_error_prefix_errno2("realpath",
+				err = got_error_from_errno2("realpath",
 				    canonpath);
 				goto done;
 			}
@@ -476,7 +476,7 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 			 */
 			path = strdup(canonpath);
 			if (path == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -494,7 +494,7 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 			free(path);
 			path = strdup("");
 			if (path == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				goto done;
 			}
 		} else if (is_repo_child && is_cwd_child) {
@@ -544,7 +544,7 @@ got_repo_map_path(char **in_repo_path, struct got_repo
 	if (path[0] != '/') {
 		char *abspath;
 		if (asprintf(&abspath, "/%s", path) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 		free(path);
@@ -630,11 +630,11 @@ got_repo_search_packidx(struct got_packidx **packidx, 
 
 	path_packdir = got_repo_get_path_objects_pack(repo);
 	if (path_packdir == NULL)
-		return got_error_prefix_errno("got_repo_get_path_objects_pack");
+		return got_error_from_errno("got_repo_get_path_objects_pack");
 
 	packdir = opendir(path_packdir);
 	if (packdir == NULL) {
-		err = got_error_prefix_errno2("opendir", path_packdir);
+		err = got_error_from_errno2("opendir", path_packdir);
 		goto done;
 	}
 
@@ -644,7 +644,7 @@ got_repo_search_packidx(struct got_packidx **packidx, 
 
 		if (asprintf(&path_packidx, "%s/%s", path_packdir,
 		    dent->d_name) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 
@@ -670,7 +670,7 @@ got_repo_search_packidx(struct got_packidx **packidx, 
 done:
 	free(path_packdir);
 	if (packdir && closedir(packdir) != 0 && err == 0)
-		err = got_error_prefix_errno("closedir");
+		err = got_error_from_errno("closedir");
 	return err;
 }
 
@@ -684,7 +684,7 @@ read_packfile_hdr(int fd, struct got_packidx *packidx)
 
 	n = read(fd, &hdr, sizeof(hdr));
 	if (n < 0)
-		return got_error_prefix_errno("read");
+		return got_error_from_errno("read");
 	if (n != sizeof(hdr))
 		return got_error(GOT_ERR_BAD_PACKFILE);
 
@@ -703,7 +703,7 @@ open_packfile(int *fd, const char *path_packfile, stru
 
 	*fd = open(path_packfile, O_RDONLY | O_NOFOLLOW);
 	if (*fd == -1)
-		return got_error_prefix_errno2("open", path_packfile);
+		return got_error_from_errno2("open", path_packfile);
 
 	if (packidx) {
 		err = read_packfile_hdr(*fd, packidx);
@@ -748,7 +748,7 @@ got_repo_cache_pack(struct got_pack **packp, struct go
 
 	pack->path_packfile = strdup(path_packfile);
 	if (pack->path_packfile == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -767,7 +767,7 @@ got_repo_cache_pack(struct got_pack **packp, struct go
 	    pack->fd, 0);
 	if (pack->map == MAP_FAILED) {
 		if (errno != ENOMEM) {
-			err = got_error_prefix_errno("mmap");
+			err = got_error_from_errno("mmap");
 			goto done;
 		}
 		pack->map = NULL; /* fall back to read(2) */
blob - 53fc4a5db64d58550cdf558c5f45e93be6eaf848
blob + 41c3f2e47158bafbf6229ab2c3b32dbb106c2e93
--- lib/utf8.c
+++ lib/utf8.c
@@ -36,7 +36,7 @@ got_mbsavis(char** outp, int *widthp, const char *mbs)
 
 	len = strlen(mbs);
 	if ((*outp = malloc(len + 1)) == NULL)
-		return got_error_prefix_errno("malloc");
+		return got_error_from_errno("malloc");
 
 	if (MB_CUR_MAX == 1) {
 		memcpy(*outp, mbs, len + 1);
blob - 9186607062c7b5c859c727a75daad76225a91a48
blob + f765f02f02a5448996609a862e8e4cbf2aa56f55
--- lib/worklist.c
+++ lib/worklist.c
@@ -48,7 +48,7 @@ worklist_add(const char *path, struct wklhead *worklis
 
 	wkl = calloc(1, sizeof(*wkl));
 	if (wkl == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	len = strlcpy(wkl->wkl_path, path, sizeof(wkl->wkl_path));
 	if (len >= sizeof(wkl->wkl_path))
blob - b6a44c48e939a16889c4bde6c791760cf4b4faf5
blob + d2ab48df22bc1599be297b1d41e5f7d98447d094
--- lib/worktree.c
+++ lib/worktree.c
@@ -65,7 +65,7 @@ create_meta_file(const char *path_got, const char *nam
 	int fd = -1;
 
 	if (asprintf(&path, "%s/%s", path_got, name) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path = NULL;
 		goto done;
 	}
@@ -73,21 +73,21 @@ create_meta_file(const char *path_got, const char *nam
 	fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
 	    GOT_DEFAULT_FILE_MODE);
 	if (fd == -1) {
-		err = got_error_prefix_errno2("open", path);
+		err = got_error_from_errno2("open", path);
 		goto done;
 	}
 
 	if (content) {
 		int len = dprintf(fd, "%s\n", content);
 		if (len != strlen(content) + 1) {
-			err = got_error_prefix_errno("dprintf");
+			err = got_error_from_errno("dprintf");
 			goto done;
 		}
 	}
 
 done:
 	if (fd != -1 && close(fd) == -1 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	free(path);
 	return err;
 }
@@ -101,7 +101,7 @@ update_meta_file(const char *path_got, const char *nam
 	char *path = NULL;
 
 	if (asprintf(&path, "%s/%s", path_got, name) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path = NULL;
 		goto done;
 	}
@@ -113,20 +113,20 @@ update_meta_file(const char *path_got, const char *nam
 	if (content) {
 		int len = fprintf(tmpfile, "%s\n", content);
 		if (len != strlen(content) + 1) {
-			err = got_error_prefix_errno2("fprintf", tmppath);
+			err = got_error_from_errno2("fprintf", tmppath);
 			goto done;
 		}
 	}
 
 	if (rename(tmppath, path) != 0) {
-		err = got_error_prefix_errno3("rename", tmppath, path);
+		err = got_error_from_errno3("rename", tmppath, path);
 		unlink(tmppath);
 		goto done;
 	}
 
 done:
 	if (fclose(tmpfile) != 0 && err == NULL)
-		err = got_error_prefix_errno2("fclose", tmppath);
+		err = got_error_from_errno2("fclose", tmppath);
 	free(tmppath);
 	return err;
 }
@@ -143,7 +143,7 @@ read_meta_file(char **content, const char *path_got, c
 	*content = NULL;
 
 	if (asprintf(&path, "%s/%s", path_got, name) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path = NULL;
 		goto done;
 	}
@@ -153,28 +153,28 @@ read_meta_file(char **content, const char *path_got, c
 		if (errno == ENOENT)
 			err = got_error(GOT_ERR_WORKTREE_META);
 		else
-			err = got_error_prefix_errno2("open", path);
+			err = got_error_from_errno2("open", path);
 		goto done;
 	}
 	if (flock(fd, LOCK_SH | LOCK_NB) == -1) {
 		err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
-		    : got_error_prefix_errno2("flock", path));
+		    : got_error_from_errno2("flock", path));
 		goto done;
 	}
 
 	if (lstat(path, &sb) != 0) {
-		err = got_error_prefix_errno2("lstat", path);
+		err = got_error_from_errno2("lstat", path);
 		goto done;
 	}
 	*content = calloc(1, sb.st_size);
 	if (*content == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
 	n = read(fd, *content, sb.st_size);
 	if (n != sb.st_size) {
-		err = (n == -1 ? got_error_prefix_errno2("read", path) :
+		err = (n == -1 ? got_error_from_errno2("read", path) :
 		    got_error(GOT_ERR_WORKTREE_META));
 		goto done;
 	}
@@ -186,7 +186,7 @@ read_meta_file(char **content, const char *path_got, c
 
 done:
 	if (fd != -1 && close(fd) == -1 && err == NULL)
-		err = got_error_prefix_errno2("close", path_got);
+		err = got_error_from_errno2("close", path_got);
 	free(path);
 	if (err) {
 		free(*content);
@@ -227,22 +227,22 @@ got_worktree_init(const char *path, struct got_referen
 
 	if (!got_path_is_absolute(prefix)) {
 		if (asprintf(&absprefix, "/%s", prefix) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	}
 
 	/* Create top-level directory (may already exist). */
 	if (mkdir(path, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
-		err = got_error_prefix_errno2("mkdir", path);
+		err = got_error_from_errno2("mkdir", path);
 		goto done;
 	}
 
 	/* Create .got directory (may already exist). */
 	if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	if (mkdir(path_got, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
-		err = got_error_prefix_errno2("mkdir", path_got);
+		err = got_error_from_errno2("mkdir", path_got);
 		goto done;
 	}
 
@@ -259,7 +259,7 @@ got_worktree_init(const char *path, struct got_referen
 	/* Write the HEAD reference. */
 	refstr = got_ref_to_str(head_ref);
 	if (refstr == NULL) {
-		err = got_error_prefix_errno("got_ref_to_str");
+		err = got_error_from_errno("got_ref_to_str");
 		goto done;
 	}
 	err = create_meta_file(path_got, GOT_WORKTREE_HEAD_REF, refstr);
@@ -303,7 +303,7 @@ got_worktree_init(const char *path, struct got_referen
 
 	/* Stamp work tree with format file. */
 	if (asprintf(&formatstr, "%d", GOT_WORKTREE_FORMAT_VERSION) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	err = create_meta_file(path_got, GOT_WORKTREE_FORMAT, formatstr);
@@ -338,13 +338,13 @@ open_worktree(struct got_worktree **worktree, const ch
 	*worktree = NULL;
 
 	if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path_got = NULL;
 		goto done;
 	}
 
 	if (asprintf(&path_lock, "%s/%s", path_got, GOT_WORKTREE_LOCK) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path_lock = NULL;
 		goto done;
 	}
@@ -352,7 +352,7 @@ open_worktree(struct got_worktree **worktree, const ch
 	fd = open(path_lock, O_RDWR | O_EXLOCK | O_NONBLOCK);
 	if (fd == -1) {
 		err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
-		    : got_error_prefix_errno2("open", path_lock));
+		    : got_error_from_errno2("open", path_lock));
 		goto done;
 	}
 
@@ -372,14 +372,14 @@ open_worktree(struct got_worktree **worktree, const ch
 
 	*worktree = calloc(1, sizeof(**worktree));
 	if (*worktree == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 	(*worktree)->lockfd = -1;
 
 	(*worktree)->root_path = strdup(path);
 	if ((*worktree)->root_path == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	err = read_meta_file(&(*worktree)->repo_path, path_got,
@@ -450,7 +450,7 @@ got_worktree_open(struct got_worktree **worktree, cons
 			return NULL;
 		path = dirname(path);
 		if (path == NULL)
-			return got_error_prefix_errno2("dirname", path);
+			return got_error_from_errno2("dirname", path);
 	} while (!((path[0] == '.' || path[0] == '/') && path[1] == '\0'));
 
 	return got_error(GOT_ERR_NOT_WORKTREE);
@@ -467,7 +467,7 @@ got_worktree_close(struct got_worktree *worktree)
 	free(worktree->head_ref_name);
 	if (worktree->lockfd != -1)
 		if (close(worktree->lockfd) != 0)
-			err = got_error_prefix_errno2("close",
+			err = got_error_from_errno2("close",
 			    got_worktree_get_root_path(worktree));
 	free(worktree);
 	return err;
@@ -499,7 +499,7 @@ got_worktree_match_path_prefix(int *match, struct got_
 
 	if (!got_path_is_absolute(path_prefix)) {
 		if (asprintf(&absprefix, "/%s", path_prefix) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	}
 	*match = (strcmp(absprefix ? absprefix : path_prefix,
 	    worktree->path_prefix) == 0);
@@ -530,7 +530,7 @@ got_worktree_set_base_commit_id(struct got_worktree *w
 
 	if (asprintf(&path_got, "%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		path_got = NULL;
 		goto done;
 	}
@@ -555,7 +555,7 @@ got_worktree_set_base_commit_id(struct got_worktree *w
 	free(worktree->base_commit_id);
 	worktree->base_commit_id = got_object_id_dup(commit_id);
 	if (worktree->base_commit_id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 done:
@@ -571,7 +571,7 @@ lock_worktree(struct got_worktree *worktree, int opera
 {
 	if (flock(worktree->lockfd, operation | LOCK_NB) == -1)
 		return (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
-		    : got_error_prefix_errno2("flock",
+		    : got_error_from_errno2("flock",
 		    got_worktree_get_root_path(worktree)));
 	return NULL;
 }
@@ -583,14 +583,14 @@ add_dir_on_disk(struct got_worktree *worktree, const c
 	char *abspath;
 
 	if (asprintf(&abspath, "%s/%s", worktree->root_path, path) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = got_path_mkdir(abspath);
 	if (err && err->code == GOT_ERR_ERRNO && errno == EEXIST) {
 		struct stat sb;
 		err = NULL;
 		if (lstat(abspath, &sb) == -1) {
-			err = got_error_prefix_errno2("lstat", abspath);
+			err = got_error_from_errno2("lstat", abspath);
 		} else if (!S_ISDIR(sb.st_mode)) {
 			/* TODO directory is obstructed; do something */
 			err = got_error(GOT_ERR_FILE_OBSTRUCTED);
@@ -613,12 +613,12 @@ check_file_contents_equal(int *same, FILE *f1, FILE *f
 	for (;;) {
 		flen1 = fread(fbuf1, 1, sizeof(fbuf1), f1);
 		if (flen1 == 0 && ferror(f1)) {
-			err = got_error_prefix_errno("fread");
+			err = got_error_from_errno("fread");
 			break;
 		}
 		flen2 = fread(fbuf2, 1, sizeof(fbuf2), f2);
 		if (flen2 == 0 && ferror(f2)) {
-			err = got_error_prefix_errno("fread");
+			err = got_error_from_errno("fread");
 			break;
 		}
 		if (flen1 == 0) {
@@ -654,13 +654,13 @@ check_files_equal(int *same, const char *f1_path, cons
 	*same = 1;
 
 	if (lstat(f1_path, &sb) != 0) {
-		err = got_error_prefix_errno2("lstat", f1_path);
+		err = got_error_from_errno2("lstat", f1_path);
 		goto done;
 	}
 	size1 = sb.st_size;
 
 	if (lstat(f2_path, &sb) != 0) {
-		err = got_error_prefix_errno2("lstat", f2_path);
+		err = got_error_from_errno2("lstat", f2_path);
 		goto done;
 	}
 	size2 = sb.st_size;
@@ -672,20 +672,20 @@ check_files_equal(int *same, const char *f1_path, cons
 
 	f1 = fopen(f1_path, "r");
 	if (f1 == NULL)
-		return got_error_prefix_errno2("open", f1_path);
+		return got_error_from_errno2("open", f1_path);
 
 	f2 = fopen(f2_path, "r");
 	if (f2 == NULL) {
-		err = got_error_prefix_errno2("open", f2_path);
+		err = got_error_from_errno2("open", f2_path);
 		goto done;
 	}
 
 	err = check_file_contents_equal(same, f1, f2);
 done:
 	if (f1 && fclose(f1) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (f2 && fclose(f2) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 
 	return err;
 }
@@ -715,10 +715,10 @@ merge_blob(struct got_worktree *worktree, struct got_f
 
 	parent = dirname(ondisk_path);
 	if (parent == NULL)
-		return got_error_prefix_errno2("dirname", ondisk_path);
+		return got_error_from_errno2("dirname", ondisk_path);
 
 	if (asprintf(&base_path, "%s/got-merged", parent) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = got_opentemp_named_fd(&merged_path, &merged_fd, base_path);
 	if (err)
@@ -726,7 +726,7 @@ merge_blob(struct got_worktree *worktree, struct got_f
 
 	free(base_path);
 	if (asprintf(&base_path, "%s/got-merge-blob1", parent) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		base_path = NULL;
 		goto done;
 	}
@@ -740,7 +740,7 @@ merge_blob(struct got_worktree *worktree, struct got_f
 
 	free(base_path);
 	if (asprintf(&base_path, "%s/got-merge-blob2", parent) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		base_path = NULL;
 		goto done;
 	}
@@ -769,7 +769,7 @@ merge_blob(struct got_worktree *worktree, struct got_f
 	if (err)
 		goto done;
 	if (asprintf(&label1, "commit %s", id_str) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -782,7 +782,7 @@ merge_blob(struct got_worktree *worktree, struct got_f
 	    overlapcnt > 0 ? GOT_STATUS_CONFLICT : GOT_STATUS_MERGE, path);
 
 	if (fsync(merged_fd) != 0) {
-		err = got_error_prefix_errno("fsync");
+		err = got_error_from_errno("fsync");
 		goto done;
 	}
 
@@ -795,12 +795,12 @@ merge_blob(struct got_worktree *worktree, struct got_f
 	}
 
 	if (chmod(merged_path, st_mode) != 0) {
-		err = got_error_prefix_errno2("chmod", merged_path);
+		err = got_error_from_errno2("chmod", merged_path);
 		goto done;
 	}
 
 	if (rename(merged_path, ondisk_path) != 0) {
-		err = got_error_prefix_errno3("rename", merged_path,
+		err = got_error_from_errno3("rename", merged_path,
 		    ondisk_path);
 		unlink(merged_path);
 		goto done;
@@ -814,11 +814,11 @@ merge_blob(struct got_worktree *worktree, struct got_f
 	    blob1->id.sha1, worktree->base_commit_id->sha1, update_timestamps);
 done:
 	if (merged_fd != -1 && close(merged_fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	if (f1 && fclose(f1) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (f2 && fclose(f2) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (blob2)
 		got_object_blob_close(blob2);
 	free(merged_path);
@@ -879,7 +879,7 @@ install_blob(struct got_worktree *worktree, const char
 		if (errno == ENOENT) {
 			char *parent = dirname(path);
 			if (parent == NULL)
-				return got_error_prefix_errno2("dirname", path);
+				return got_error_from_errno2("dirname", path);
 			err = add_dir_on_disk(worktree, parent);
 			if (err)
 				return err;
@@ -887,7 +887,7 @@ install_blob(struct got_worktree *worktree, const char
 			    O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
 			    GOT_DEFAULT_FILE_MODE);
 			if (fd == -1)
-				return got_error_prefix_errno2("open",
+				return got_error_from_errno2("open",
 				    ondisk_path);
 		} else if (errno == EEXIST) {
 			if (!S_ISREG(st_mode)) {
@@ -902,7 +902,7 @@ install_blob(struct got_worktree *worktree, const char
 				update = 1;
 			}
 		} else
-			return got_error_prefix_errno2("open", ondisk_path);
+			return got_error_from_errno2("open", ondisk_path);
 	}
 
 	if (restoring_missing_file)
@@ -923,7 +923,7 @@ install_blob(struct got_worktree *worktree, const char
 			/* Skip blob object header first time around. */
 			ssize_t outlen = write(fd, buf + hdrlen, len - hdrlen);
 			if (outlen == -1) {
-				err = got_error_prefix_errno("write");
+				err = got_error_from_errno("write");
 				goto done;
 			} else if (outlen != len - hdrlen) {
 				err = got_error(GOT_ERR_IO);
@@ -934,13 +934,13 @@ install_blob(struct got_worktree *worktree, const char
 	} while (len != 0);
 
 	if (fsync(fd) != 0) {
-		err = got_error_prefix_errno("fsync");
+		err = got_error_from_errno("fsync");
 		goto done;
 	}
 
 	if (update) {
 		if (rename(tmppath, ondisk_path) != 0) {
-			err = got_error_prefix_errno3("rename", tmppath,
+			err = got_error_from_errno3("rename", tmppath,
 			    ondisk_path);
 			unlink(tmppath);
 			goto done;
@@ -949,19 +949,19 @@ install_blob(struct got_worktree *worktree, const char
 
 	if (te_mode & S_IXUSR) {
 		if (chmod(ondisk_path, st_mode | S_IXUSR) == -1) {
-			err = got_error_prefix_errno2("chmod", ondisk_path);
+			err = got_error_from_errno2("chmod", ondisk_path);
 			goto done;
 		}
 	} else {
 		if (chmod(ondisk_path, st_mode & ~S_IXUSR) == -1) {
-			err = got_error_prefix_errno2("chmod", ondisk_path);
+			err = got_error_from_errno2("chmod", ondisk_path);
 			goto done;
 		}
 	}
 
 done:
 	if (fd != -1 && close(fd) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	free(tmppath);
 	return err;
 }
@@ -1031,7 +1031,7 @@ get_file_status(unsigned char *status, struct stat *sb
 				sb->st_mode = GOT_DEFAULT_FILE_MODE;
 			return NULL;
 		}
-		return got_error_prefix_errno2("lstat", abspath);
+		return got_error_from_errno2("lstat", abspath);
 	}
 
 	if (!S_ISREG(sb->st_mode)) {
@@ -1065,7 +1065,7 @@ get_file_status(unsigned char *status, struct stat *sb
 
 	f = fopen(abspath, "r");
 	if (f == NULL) {
-		err = got_error_prefix_errno2("fopen", abspath);
+		err = got_error_from_errno2("fopen", abspath);
 		goto done;
 	}
 	hdrlen = got_object_blob_get_hdrlen(blob);
@@ -1077,7 +1077,7 @@ get_file_status(unsigned char *status, struct stat *sb
 		/* Skip length of blob object header first time around. */
 		flen = fread(fbuf, 1, sizeof(fbuf) - hdrlen, f);
 		if (flen == 0 && ferror(f)) {
-			err = got_error_prefix_errno("fread");
+			err = got_error_from_errno("fread");
 			goto done;
 		}
 		if (blen == 0) {
@@ -1127,7 +1127,7 @@ update_blob(struct got_worktree *worktree,
 	struct stat sb;
 
 	if (asprintf(&ondisk_path, "%s/%s", worktree->root_path, path) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = get_file_status(&status, &sb, ie, ondisk_path, repo);
 	if (err)
@@ -1190,17 +1190,17 @@ remove_ondisk_file(const char *root_path, const char *
 	char *ondisk_path = NULL;
 
 	if (asprintf(&ondisk_path, "%s/%s", root_path, path) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	if (unlink(ondisk_path) == -1) {
 		if (errno != ENOENT)
-			err = got_error_prefix_errno2("unlink", ondisk_path);
+			err = got_error_from_errno2("unlink", ondisk_path);
 	} else {
 		char *parent = dirname(ondisk_path);
 		while (parent && strcmp(parent, root_path) != 0) {
 			if (rmdir(parent) == -1) {
 				if (errno != ENOTEMPTY)
-					err = got_error_prefix_errno2("rmdir",
+					err = got_error_from_errno2("rmdir",
 					    parent);
 				break;
 			}
@@ -1224,7 +1224,7 @@ delete_blob(struct got_worktree *worktree, struct got_
 
 	if (asprintf(&ondisk_path, "%s/%s", worktree->root_path, ie->path)
 	    == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = get_file_status(&status, &sb, ie, ondisk_path, repo);
 	if (err)
@@ -1302,7 +1302,7 @@ diff_new(void *arg, struct got_tree_entry *te, const c
 	if (asprintf(&path, "%s%s%s", parent_path,
 	    parent_path[0] ? "/" : "", te->name)
 	    == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	if (S_ISDIR(te->mode))
 		err = add_dir_on_disk(a->worktree, path);
@@ -1329,7 +1329,7 @@ got_worktree_get_base_ref_name(char **refname, struct 
 
 	if (asprintf(refname, "%s-%s", GOT_WORKTREE_BASE_REF_PREFIX, uuidstr)
 	    == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		*refname = NULL;
 	}
 	free(uuidstr);
@@ -1373,11 +1373,11 @@ open_fileindex(struct got_fileindex **fileindex, char 
 	*fileindex_path = NULL;
 	*fileindex = got_fileindex_alloc();
 	if (*fileindex == NULL)
-		return got_error_prefix_errno("got_fileindex_alloc");
+		return got_error_from_errno("got_fileindex_alloc");
 
 	if (asprintf(fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		*fileindex_path = NULL;
 		goto done;
 	}
@@ -1385,11 +1385,11 @@ open_fileindex(struct got_fileindex **fileindex, char 
 	index = fopen(*fileindex_path, "rb");
 	if (index == NULL) {
 		if (errno != ENOENT)
-			err = got_error_prefix_errno2("fopen", *fileindex_path);
+			err = got_error_from_errno2("fopen", *fileindex_path);
 	} else {
 		err = got_fileindex_read(*fileindex, index);
 		if (fclose(index) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 done:
 	if (err) {
@@ -1449,13 +1449,13 @@ got_worktree_checkout_files(struct got_worktree *workt
 		int obj_type;
 		relpath = strdup(path);
 		if (relpath == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		if (asprintf(&tree_path, "%s%s%s", worktree->path_prefix,
 		    got_path_is_root_dir(worktree->path_prefix) ? "" : "/",
 		    path) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 		err = got_object_id_by_path(&tree_id, repo,
@@ -1471,12 +1471,12 @@ got_worktree_checkout_files(struct got_worktree *workt
 			if (strchr(path, '/')  == NULL) {
 				relpath = strdup("");
 				if (relpath == NULL) {
-					err = got_error_prefix_errno("strdup");
+					err = got_error_from_errno("strdup");
 					goto done;
 				}
 				tree_path = strdup(worktree->path_prefix);
 				if (tree_path == NULL) {
-					err = got_error_prefix_errno("strdup");
+					err = got_error_from_errno("strdup");
 					goto done;
 				}
 			} else {
@@ -1488,7 +1488,7 @@ got_worktree_checkout_files(struct got_worktree *workt
 				    got_path_is_root_dir(
 				    worktree->path_prefix) ? "" : "/",
 				    relpath) == -1) {
-					err = got_error_prefix_errno("asprintf");
+					err = got_error_from_errno("asprintf");
 					goto done;
 				}
 			}
@@ -1499,14 +1499,14 @@ got_worktree_checkout_files(struct got_worktree *workt
 				goto done;
 			entry_name = basename(path);
 			if (entry_name == NULL) {
-				err = got_error_prefix_errno2("basename", path);
+				err = got_error_from_errno2("basename", path);
 				goto done;
 			}
 		}
 	} else {
 		relpath = strdup("");
 		if (relpath == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		err = got_object_id_by_path(&tree_id, repo,
@@ -1544,7 +1544,7 @@ got_worktree_checkout_files(struct got_worktree *workt
 		goto done;
 
 	if (rename(new_fileindex_path, fileindex_path) != 0) {
-		err = got_error_prefix_errno3("rename", new_fileindex_path,
+		err = got_error_from_errno3("rename", new_fileindex_path,
 		    fileindex_path);
 		unlink(new_fileindex_path);
 		goto done;
@@ -1622,11 +1622,11 @@ status_old_new(void *arg, struct got_fileindex_entry *
 	if (parent_path[0]) {
 		if (asprintf(&abspath, "%s/%s/%s", a->worktree->root_path,
 		    parent_path, de->d_name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	} else {
 		if (asprintf(&abspath, "%s/%s", a->worktree->root_path,
 		    de->d_name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	}
 
 	err = report_file_status(ie, abspath, a->status_cb, a->status_arg,
@@ -1678,7 +1678,7 @@ status_new(void *arg, struct dirent *de, const char *p
 
 	if (parent_path[0]) {
 		if (asprintf(&path, "%s/%s", parent_path, de->d_name) == -1)
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 	} else {
 		path = de->d_name;
 	}
@@ -1706,13 +1706,13 @@ got_worktree_status(struct got_worktree *worktree, con
 
 	fileindex = got_fileindex_alloc();
 	if (fileindex == NULL) {
-		err = got_error_prefix_errno("got_fileindex_alloc");
+		err = got_error_from_errno("got_fileindex_alloc");
 		goto done;
 	}
 
 	if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		fileindex_path = NULL;
 		goto done;
 	}
@@ -1720,7 +1720,7 @@ got_worktree_status(struct got_worktree *worktree, con
 	index = fopen(fileindex_path, "rb");
 	if (index == NULL) {
 		if (errno != ENOENT) {
-			err = got_error_prefix_errno2("fopen", fileindex_path);
+			err = got_error_from_errno2("fopen", fileindex_path);
 			goto done;
 		}
 	} else {
@@ -1732,7 +1732,7 @@ got_worktree_status(struct got_worktree *worktree, con
 
 	if (asprintf(&ondisk_path, "%s%s%s",
 	    worktree->root_path, path[0] ? "/" : "", path) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	workdir = opendir(ondisk_path);
@@ -1748,7 +1748,7 @@ got_worktree_status(struct got_worktree *worktree, con
 			    status_cb, status_arg, repo);
 			goto done;
 		} else {
-			err = got_error_prefix_errno2("opendir", ondisk_path);
+			err = got_error_from_errno2("opendir", ondisk_path);
 			goto done;
 		}
 	}
@@ -1787,7 +1787,7 @@ got_worktree_resolve_path(char **wt_path, struct got_w
 
 	resolved = realpath(arg, NULL);
 	if (resolved == NULL)
-		return got_error_prefix_errno2("realpath", arg);
+		return got_error_from_errno2("realpath", arg);
 
 	if (strncmp(got_worktree_get_root_path(worktree), resolved,
 	    strlen(got_worktree_get_root_path(worktree)))) {
@@ -1798,7 +1798,7 @@ got_worktree_resolve_path(char **wt_path, struct got_w
 	path = strdup(resolved +
 	    strlen(got_worktree_get_root_path(worktree)) + 1 /* skip '/' */);
 	if (path == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -1836,20 +1836,20 @@ got_worktree_schedule_add(struct got_worktree *worktre
 
 	fileindex = got_fileindex_alloc();
 	if (fileindex == NULL) {
-		err = got_error_prefix_errno("got_fileindex_alloc");
+		err = got_error_from_errno("got_fileindex_alloc");
 		goto done;
 	}
 
 	if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		fileindex_path = NULL;
 		goto done;
 	}
 
 	index = fopen(fileindex_path, "rb");
 	if (index == NULL) {
-		err = got_error_prefix_errno2("fopen", fileindex_path);
+		err = got_error_from_errno2("fopen", fileindex_path);
 		goto done;
 	}
 
@@ -1898,7 +1898,7 @@ got_worktree_schedule_add(struct got_worktree *worktre
 		goto done;
 
 	if (rename(new_fileindex_path, fileindex_path) != 0) {
-		err = got_error_prefix_errno3("rename", new_fileindex_path,
+		err = got_error_from_errno3("rename", new_fileindex_path,
 		    fileindex_path);
 		goto done;
 	}
@@ -1909,11 +1909,11 @@ got_worktree_schedule_add(struct got_worktree *worktre
 done:
 	if (index) {
 		if (fclose(index) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	if (new_fileindex_path) {
 		if (unlink(new_fileindex_path) != 0 && err == NULL)
-			err = got_error_prefix_errno2("unlink",
+			err = got_error_from_errno2("unlink",
 			    new_fileindex_path);
 		free(new_fileindex_path);
 	}
@@ -1950,20 +1950,20 @@ got_worktree_schedule_delete(struct got_worktree *work
 
 	fileindex = got_fileindex_alloc();
 	if (fileindex == NULL) {
-		err = got_error_prefix_errno("got_fileindex_alloc");
+		err = got_error_from_errno("got_fileindex_alloc");
 		goto done;
 	}
 
 	if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		fileindex_path = NULL;
 		goto done;
 	}
 
 	index = fopen(fileindex_path, "rb");
 	if (index == NULL) {
-		err = got_error_prefix_errno2("fopen", fileindex_path);
+		err = got_error_from_errno2("fopen", fileindex_path);
 		goto done;
 	}
 
@@ -1997,7 +1997,7 @@ got_worktree_schedule_delete(struct got_worktree *work
 	}
 
 	if (unlink(ondisk_path) != 0) {
-		err = got_error_prefix_errno2("unlink", ondisk_path);
+		err = got_error_from_errno2("unlink", ondisk_path);
 		goto done;
 	}
 
@@ -2013,7 +2013,7 @@ got_worktree_schedule_delete(struct got_worktree *work
 		goto done;
 
 	if (rename(new_fileindex_path, fileindex_path) != 0) {
-		err = got_error_prefix_errno3("rename", new_fileindex_path,
+		err = got_error_from_errno3("rename", new_fileindex_path,
 		    fileindex_path);
 		goto done;
 	}
@@ -2026,11 +2026,11 @@ done:
 	free(relpath);
 	if (index) {
 		if (fclose(index) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	if (new_fileindex_path) {
 		if (unlink(new_fileindex_path) != 0 && err == NULL)
-			err = got_error_prefix_errno2("unlink",
+			err = got_error_from_errno2("unlink",
 			    new_fileindex_path);
 		free(new_fileindex_path);
 	}
@@ -2072,20 +2072,20 @@ got_worktree_revert(struct got_worktree *worktree,
 
 	fileindex = got_fileindex_alloc();
 	if (fileindex == NULL) {
-		err = got_error_prefix_errno("got_fileindex_alloc");
+		err = got_error_from_errno("got_fileindex_alloc");
 		goto done;
 	}
 
 	if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
 	    GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		fileindex_path = NULL;
 		goto done;
 	}
 
 	index = fopen(fileindex_path, "rb");
 	if (index == NULL) {
-		err = got_error_prefix_errno2("fopen", fileindex_path);
+		err = got_error_from_errno2("fopen", fileindex_path);
 		goto done;
 	}
 
@@ -2109,20 +2109,20 @@ got_worktree_revert(struct got_worktree *worktree,
 	if (got_path_is_root_dir(worktree->path_prefix)) {
 		tree_path = strdup(parent_path);
 		if (tree_path == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else {
 		if (got_path_is_root_dir(parent_path)) {
 			tree_path = strdup(worktree->path_prefix);
 			if (tree_path == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				goto done;
 			}
 		} else {
 			if (asprintf(&tree_path, "%s/%s",
 			    worktree->path_prefix, parent_path) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				goto done;
 			}
 		}
@@ -2139,7 +2139,7 @@ got_worktree_revert(struct got_worktree *worktree,
 
 	te_name = basename(ie->path);
 	if (te_name == NULL) {
-		err = got_error_prefix_errno2("basename", ie->path);
+		err = got_error_from_errno2("basename", ie->path);
 		goto done;
 	}
 
@@ -2192,7 +2192,7 @@ got_worktree_revert(struct got_worktree *worktree,
 		goto done;
 
 	if (rename(new_fileindex_path, fileindex_path) != 0) {
-		err = got_error_prefix_errno3("rename", new_fileindex_path,
+		err = got_error_from_errno3("rename", new_fileindex_path,
 		    fileindex_path);
 		goto done;
 	}
@@ -2209,11 +2209,11 @@ done:
 	free(tree_id);
 	if (index) {
 		if (fclose(index) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 	}
 	if (new_fileindex_path) {
 		if (unlink(new_fileindex_path) != 0 && err == NULL)
-			err = got_error_prefix_errno2("unlink",
+			err = got_error_from_errno2("unlink",
 			    new_fileindex_path);
 		free(new_fileindex_path);
 	}
@@ -2261,13 +2261,13 @@ collect_commitables(void *arg, unsigned char status, c
 		return NULL;
 
 	if (asprintf(&path, "/%s", relpath) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	if (strcmp(path, "/") == 0) {
 		parent_path = strdup("");
 		if (parent_path == NULL)
-			return got_error_prefix_errno("strdup");
+			return got_error_from_errno("strdup");
 	} else {
 		err = got_path_dirname(&parent_path, path);
 		if (err)
@@ -2276,20 +2276,20 @@ collect_commitables(void *arg, unsigned char status, c
 
 	ct = calloc(1, sizeof(*ct));
 	if (ct == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
 	if (asprintf(&ct->ondisk_path, "%s/%s", a->worktree->root_path,
 	    relpath) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	if (status == GOT_STATUS_DELETE) {
 		sb.st_mode = GOT_DEFAULT_FILE_MODE;
 	} else {
 		if (lstat(ct->ondisk_path, &sb) != 0) {
-			err = got_error_prefix_errno2("lstat", ct->ondisk_path);
+			err = got_error_from_errno2("lstat", ct->ondisk_path);
 			goto done;
 		}
 		ct->mode = sb.st_mode;
@@ -2298,7 +2298,7 @@ collect_commitables(void *arg, unsigned char status, c
 	if (asprintf(&ct->in_repo_path, "%s%s%s", a->worktree->path_prefix,
 	    got_path_is_root_dir(a->worktree->path_prefix) ? "" : "/",
 	    relpath) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -2307,13 +2307,13 @@ collect_commitables(void *arg, unsigned char status, c
 	if (ct->status != GOT_STATUS_ADD) {
 		ct->base_id = got_object_id_dup(id);
 		if (ct->base_id == NULL) {
-			err = got_error_prefix_errno("got_object_id_dup");
+			err = got_error_from_errno("got_object_id_dup");
 			goto done;
 		}
 	}
 	ct->path = strdup(path);
 	if (ct->path == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	err = got_pathlist_insert(&new, a->commitable_paths, ct->path, ct);
@@ -2343,7 +2343,7 @@ write_subtree(struct got_object_id **new_subtree_id,
 
 	if (asprintf(&subpath, "%s%s%s", parent_path,
 	    got_path_is_root_dir(parent_path) ? "" : "/", te->name) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	err = got_object_open_as_tree(&subtree, repo, te->id);
 	if (err)
@@ -2400,7 +2400,7 @@ alloc_modified_blob_tree_entry(struct got_tree_entry *
 	free((*new_te)->id);
 	(*new_te)->id = got_object_id_dup(ct->blob_id);
 	if ((*new_te)->id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 done:
@@ -2422,16 +2422,16 @@ alloc_added_blob_tree_entry(struct got_tree_entry **ne
 
 	*new_te = calloc(1, sizeof(**new_te));
 	if (*new_te == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	ct_name = basename(ct->path);
 	if (ct_name == NULL) {
-		err = got_error_prefix_errno2("basename", ct->path);
+		err = got_error_from_errno2("basename", ct->path);
 		goto done;
 	}
 	(*new_te)->name = strdup(ct_name);
 	if ((*new_te)->name == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -2439,7 +2439,7 @@ alloc_added_blob_tree_entry(struct got_tree_entry **ne
 
 	(*new_te)->id = got_object_id_dup(ct->blob_id);
 	if ((*new_te)->id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 done:
@@ -2488,7 +2488,7 @@ match_modified_subtree(int *modified, struct got_tree_
 	if (asprintf(&te_path, "%s%s%s", base_tree_path,
 	    got_path_is_root_dir(base_tree_path) ? "" : "/",
 	    te->name) == -1)
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 
 	TAILQ_FOREACH(pe, commitable_paths, entry) {
 		struct got_commitable *ct = pe->data;
@@ -2532,7 +2532,7 @@ match_deleted_or_modified_ct(struct got_commitable **c
 
 		ct_name = basename(pe->path);
 		if (ct_name == NULL)
-			return got_error_prefix_errno2("basename", pe->path);
+			return got_error_from_errno2("basename", pe->path);
 
 		if (strcmp(te->name, ct_name) != 0)
 			continue;
@@ -2596,7 +2596,7 @@ write_tree(struct got_object_id **new_tree_id,
 			if (asprintf(&subtree_path, "%s%s%s", path_base_tree,
 			    got_path_is_root_dir(path_base_tree) ? "" : "/",
 			    child_path) == -1) {
-				err = got_error_prefix_errno("asprintf");
+				err = got_error_from_errno("asprintf");
 				goto done;
 			}
 			TAILQ_FOREACH(pe2, &paths, entry) {
@@ -2614,7 +2614,7 @@ write_tree(struct got_object_id **new_tree_id,
 			new_te->mode = S_IFDIR;
 			new_te->name = strdup(child_path);
 			if (new_te->name == NULL) {
-				err = got_error_prefix_errno("strdup");
+				err = got_error_from_errno("strdup");
 				got_object_tree_entry_close(new_te);
 				new_te = NULL;
 				goto done;
@@ -2753,7 +2753,7 @@ update_fileindex_after_commit(struct got_pathlist_head
 		goto done;
 
 	if (rename(new_fileindex_path, fileindex_path) != 0) {
-		err = got_error_prefix_errno3("rename", new_fileindex_path,
+		err = got_error_from_errno3("rename", new_fileindex_path,
 		    fileindex_path);
 		unlink(new_fileindex_path);
 		goto done;
@@ -2904,7 +2904,7 @@ got_worktree_commit(struct got_object_id **new_commit_
 
 		if (asprintf(&ondisk_path, "%s/%s",
 		    worktree->root_path, pe->path) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			goto done;
 		}
 		err = got_object_blob_create(&ct->blob_id, ondisk_path, repo);
@@ -2934,7 +2934,7 @@ got_worktree_commit(struct got_object_id **new_commit_
 	/* Check if a concurrent commit to our branch has occurred. */
 	head_ref_name = got_worktree_get_head_ref_name(worktree);
 	if (head_ref_name == NULL) {
-		err = got_error_prefix_errno("got_worktree_get_head_ref_name");
+		err = got_error_from_errno("got_worktree_get_head_ref_name");
 		goto done;
 	}
 	/* Lock the reference here to prevent concurrent modification. */
blob - f28286daed294ffb777009a1fddf3d4b82b5d856
blob + 983478ce1555e8fa55323e842c72c6927facc1b9
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -134,13 +134,13 @@ main(int argc, char *argv[])
 			goto done;
 
 		if (lseek(imsg.fd, SEEK_SET, 0) == -1) {
-			err = got_error_prefix_errno("lseek");
+			err = got_error_from_errno("lseek");
 			goto done;
 		}
 
 		f = fdopen(imsg.fd, "rb");
 		if (f == NULL) {
-			err = got_error_prefix_errno("fdopen");
+			err = got_error_from_errno("fdopen");
 			goto done;
 		}
 
@@ -163,14 +163,14 @@ main(int argc, char *argv[])
 done:
 		if (f) {
 			if (fclose(f) != 0 && err == NULL)
-				err = got_error_prefix_errno("fclose");
+				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
-				err = got_error_prefix_errno("close");
+				err = got_error_from_errno("close");
 		}
 		if (imsg_outfd.fd != -1) {
 			if (close(imsg_outfd.fd) != 0 && err == NULL)
-				err = got_error_prefix_errno("close");
+				err = got_error_from_errno("close");
 		}
 
 		imsg_free(&imsg);
@@ -189,6 +189,6 @@ done:
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - b015c3522f885fade88efdbd587bc655cb57984e
blob + f2dc8530f505f8258e2e20cdc61b83edee6dd969
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
@@ -95,7 +95,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
 		/* Always assume file offset zero. */
 		f = fdopen(imsg.fd, "rb");
 		if (f == NULL) {
-			err = got_error_prefix_errno("fdopen");
+			err = got_error_from_errno("fdopen");
 			goto done;
 		}
 
@@ -146,10 +146,10 @@ main(int argc, char *argv[])
 done:
 		if (f) {
 			if (fclose(f) != 0 && err == NULL)
-				err = got_error_prefix_errno("fclose");
+				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
-				err = got_error_prefix_errno("close");
+				err = got_error_from_errno("close");
 		}
 		imsg_free(&imsg);
 		if (err)
@@ -164,6 +164,6 @@ done:
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - f3b5792c26407f6760130ae763cbbfdb0ad0374a
blob + 0101bb0c03486ff728a5c9e538f96cc5b627bff2
--- libexec/got-read-object/got-read-object.c
+++ libexec/got-read-object/got-read-object.c
@@ -72,7 +72,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -112,7 +112,7 @@ main(int argc, char *argv[])
 		err = got_privsep_send_obj(&ibuf, obj);
 done:
 		if (close(imsg.fd) != 0 && err == NULL)
-			err = got_error_prefix_errno("close");
+			err = got_error_from_errno("close");
 		imsg_free(&imsg);
 		if (obj)
 			got_object_close(obj);
@@ -128,6 +128,6 @@ done:
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - 509295efffc3b0c4ab0b72c400398ae7d0b91bcc
blob + 3952d83a577c5510f0af5c58e08788892c81184c
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -203,7 +203,7 @@ receive_file(FILE **f, struct imsgbuf *ibuf, int imsg_
 
 	*f = fdopen(imsg.fd, "w+");
 	if (*f == NULL) {
-		err = got_error_prefix_errno("fdopen");
+		err = got_error_from_errno("fdopen");
 		close(imsg.fd);
 		goto done;
 	}
@@ -265,11 +265,11 @@ blob_request(struct imsg *imsg, struct imsgbuf *ibuf, 
 done:
 	free(buf);
 	if (outfile && fclose(outfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
-	if (basefile && fclose(basefile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
+	if (basefile && fclose(basefile) != 0 && err == NULL)
+		err = got_error_from_errno("fclose");
 	if (accumfile && fclose(accumfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	if (obj)
 		got_object_close(obj);
 	if (err && err->code != GOT_ERR_PRIVSEP_PIPE)
@@ -342,7 +342,7 @@ receive_packidx(struct got_packidx **packidx, struct i
 
 	p = calloc(1, sizeof(*p));
 	if (p == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -366,11 +366,11 @@ receive_packidx(struct got_packidx **packidx, struct i
 	p->len = ipackidx.len;
 	p->fd = dup(imsg.fd);
 	if (p->fd == -1) {
-		err = got_error_prefix_errno("dup");
+		err = got_error_from_errno("dup");
 		goto done;
 	}
 	if (lseek(p->fd, 0, SEEK_SET) == -1) {
-		err = got_error_prefix_errno("lseek");
+		err = got_error_from_errno("lseek");
 		goto done;
 	}
 
@@ -408,7 +408,7 @@ receive_pack(struct got_pack **packp, struct imsgbuf *
 
 	pack = calloc(1, sizeof(*pack));
 	if (pack == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -432,16 +432,16 @@ receive_pack(struct got_pack **packp, struct imsgbuf *
 	pack->filesize = ipack.filesize;
 	pack->fd = dup(imsg.fd);
 	if (pack->fd == -1) {
-		err = got_error_prefix_errno("dup");
+		err = got_error_from_errno("dup");
 		goto done;
 	}
 	if (lseek(pack->fd, 0, SEEK_SET) == -1) {
-		err = got_error_prefix_errno("lseek");
+		err = got_error_from_errno("lseek");
 		goto done;
 	}
 	pack->path_packfile = strdup(ipack.path_packfile);
 	if (pack->path_packfile == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -481,7 +481,7 @@ main(int argc, char *argv[])
 
 	err = got_object_cache_init(&objcache, GOT_OBJECT_CACHE_TYPE_OBJ);
 	if (err) {
-		err = got_error_prefix_errno("got_object_cache_init");
+		err = got_error_from_errno("got_object_cache_init");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -489,7 +489,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -552,7 +552,7 @@ main(int argc, char *argv[])
 		}
 
 		if (imsg.fd != -1 && close(imsg.fd) != 0 && err == NULL)
-			err = got_error_prefix_errno("close");
+			err = got_error_from_errno("close");
 		imsg_free(&imsg);
 		if (err)
 			break;
@@ -571,6 +571,6 @@ main(int argc, char *argv[])
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - aff70b3e271c5d54f9f704c9c34232819a7caa28
blob + cff236e8d51c7308f89a0a4787c0db0df97f3bc2
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
@@ -90,7 +90,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -129,7 +129,7 @@ main(int argc, char *argv[])
 		/* Always assume file offset zero. */
 		f = fdopen(imsg.fd, "rb");
 		if (f == NULL) {
-			err = got_error_prefix_errno("fdopen");
+			err = got_error_from_errno("fdopen");
 			goto done;
 		}
 
@@ -141,10 +141,10 @@ main(int argc, char *argv[])
 done:
 		if (f) {
 			if (fclose(f) != 0 && err == NULL)
-				err = got_error_prefix_errno("fclose");
+				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
-				err = got_error_prefix_errno("close");
+				err = got_error_from_errno("close");
 		}
 		imsg_free(&imsg);
 		if (err)
@@ -159,6 +159,6 @@ done:
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - c3fc7aaef2ffafb2c1a8ba22f252b2d18482d347
blob + 8d4fb58038502b1440ee93c55d0794ed50eafdc0
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
 #ifndef PROFILE
 	/* revoke access to most system calls */
 	if (pledge("stdio recvfd", NULL) == -1) {
-		err = got_error_prefix_errno("pledge");
+		err = got_error_from_errno("pledge");
 		got_privsep_send_error(&ibuf, err);
 		return 1;
 	}
@@ -128,7 +128,7 @@ main(int argc, char *argv[])
 		/* Always assume file offset zero. */
 		f = fdopen(imsg.fd, "rb");
 		if (f == NULL) {
-			err = got_error_prefix_errno("fdopen");
+			err = got_error_from_errno("fdopen");
 			goto done;
 		}
 
@@ -140,10 +140,10 @@ main(int argc, char *argv[])
 done:
 		if (f) {
 			if (fclose(f) != 0 && err == NULL)
-				err = got_error_prefix_errno("fclose");
+				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
-				err = got_error_prefix_errno("close");
+				err = got_error_from_errno("close");
 		}
 		imsg_free(&imsg);
 		if (err)
@@ -158,6 +158,6 @@ done:
 		}
 	}
 	if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
-		err = got_error_prefix_errno("close");
+		err = got_error_from_errno("close");
 	return err ? 1 : 0;
 }
blob - 7310a6d1b805676beb32c6da1a10e6d0b2256d46
blob + 5f086a5558ca0997cb705fa354cdcf4e673e29b3
--- regress/delta/delta_test.c
+++ regress/delta/delta_test.c
@@ -73,7 +73,7 @@ delta_apply(void)
 
 		base_file = got_opentemp();
 		if (base_file == NULL) {
-			err = got_error_prefix_errno("got_opentemp");
+			err = got_error_from_errno("got_opentemp");
 			break;
 		}
 
@@ -87,7 +87,7 @@ delta_apply(void)
 		err = got_delta_apply(base_file, dt->delta, dt->delta_len,
 		    result_file, &result_len);
 		if (fclose(base_file) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 		if (dt->expected == NULL) {
 			/* Invalid delta, expect an error. */
 			if (err == NULL)
blob - a42e23795b0488e27d70d33563f89f50c7b77e47
blob + 9a8671fcef058130186736a3dc39b490362cc7ef
--- regress/idset/idset_test.c
+++ regress/idset/idset_test.c
@@ -72,7 +72,7 @@ idset_add_remove_iter(void)
 
 	set = got_object_idset_alloc();
 	if (set == NULL) {
-		err = got_error_prefix_errno("got_object_idset_alloc");
+		err = got_error_from_errno("got_object_idset_alloc");
 		goto done;
 	}
 	if (got_object_idset_num_elements(set) != 0) {
blob - 1c8251f97cb80f83b6ae8a4939b6cee9122d311d
blob + a55620128ddb9624806e98d9ca7ae693ec0db127
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
@@ -109,7 +109,7 @@ print_tree_object(struct got_object_id *id, char *pare
 		free(hex);
 
 		if (asprintf(&next_parent, "%s/%s", parent, te->name) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			break;
 		}
 
@@ -339,7 +339,7 @@ repo_diff_blob(const char *repo_path)
 		i++;
 	}
 	if (fclose(outfile) != 0 && err == NULL)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	test_printf("\n");
 	if (i != nitems(expected_output) + 1) {
 		test_printf("number of lines expected: %d; actual: %d\n",
@@ -422,26 +422,26 @@ apply_unveil(const char *repo_path)
 	if (repo_path) {
 		normpath = got_path_normalize(repo_path);
 		if (normpath == NULL)
-			return got_error_prefix_errno("got_path_normalize");
+			return got_error_from_errno("got_path_normalize");
 		if (unveil(normpath, "r") != 0) {
 			free(normpath);
-			return got_error_prefix_errno2("unveil", normpath);
+			return got_error_from_errno2("unveil", normpath);
 		}
 		free(normpath);
 	}
 
 	if (unveil("/tmp", "rwc") != 0)
-		return got_error_prefix_errno2("unveil", "/tmp");
+		return got_error_from_errno2("unveil", "/tmp");
 
 	if (unveil("/dev/null", "rwc") != 0)
-		return got_error_prefix_errno2("unveil", "/dev/null");
+		return got_error_from_errno2("unveil", "/dev/null");
 
 	error = got_privsep_unveil_exec_helpers();
 	if (error != NULL)
 		return error;
 
 	if (unveil(NULL, NULL) != 0)
-		return got_error_prefix_errno("unveil");
+		return got_error_from_errno("unveil");
 
 	return NULL;
 }
blob - 316594959a4c54ced16b129f9a2a60abedc9cd5e
blob + 6cfa9eaa9e5fdee1f354906a1eed74177f0f7f6d
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
@@ -96,7 +96,7 @@ remove_worktree_base_ref(struct got_worktree *worktree
 		return err;
 
 	if (asprintf(&absrefname, "refs/%s", refname) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 	err = got_ref_open(&base_ref, repo, absrefname, 0);
blob - c2a87f69d252f86fabb58aaab28cc97eec77d719
blob + f5d14d2ad18f52e6ac7f6ee94f09ccdbf29f844f
--- tog/tog.c
+++ tog/tog.c
@@ -387,7 +387,7 @@ view_splitscreen(struct tog_view *view)
 		return err;
 
 	if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
-		return got_error_prefix_errno("mvwin");
+		return got_error_from_errno("mvwin");
 
 	return NULL;
 }
@@ -408,7 +408,7 @@ view_fullscreen(struct tog_view *view)
 		return err;
 
 	if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
-		return got_error_prefix_errno("mvwin");
+		return got_error_from_errno("mvwin");
 
 	return NULL;
 }
@@ -435,9 +435,9 @@ view_resize(struct tog_view *view)
 		ncols = view->ncols + (COLS - view->cols);
 
 	if (wresize(view->window, nlines, ncols) == ERR)
-		return got_error_prefix_errno("wresize");
+		return got_error_from_errno("wresize");
 	if (replace_panel(view->panel, view->window) == ERR)
-		return got_error_prefix_errno("replace_panel");
+		return got_error_from_errno("replace_panel");
 	wclear(view->window);
 
 	view->nlines = nlines;
@@ -790,7 +790,7 @@ mbs2ws(wchar_t **ws, size_t *wlen, const char *s)
 	if (*wlen == (size_t)-1) {
 		int vislen;
 		if (errno != EILSEQ)
-			return got_error_prefix_errno("mbstowcs");
+			return got_error_from_errno("mbstowcs");
 
 		/* byte string invalid in current encoding; try to "fix" it */
 		err = got_mbsavis(&vis, &vislen, s);
@@ -798,19 +798,19 @@ mbs2ws(wchar_t **ws, size_t *wlen, const char *s)
 			return err;
 		*wlen = mbstowcs(NULL, vis, 0);
 		if (*wlen == (size_t)-1) {
-			err = got_error_prefix_errno("mbstowcs"); /* give up */
+			err = got_error_from_errno("mbstowcs"); /* give up */
 			goto done;
 		}
 	}
 
 	*ws = calloc(*wlen + 1, sizeof(*ws));
 	if (*ws == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
 	if (mbstowcs(*ws, vis ? vis : s, *wlen) != *wlen)
-		err = got_error_prefix_errno("mbstowcs");
+		err = got_error_from_errno("mbstowcs");
 done:
 	free(vis);
 	if (err) {
@@ -857,7 +857,7 @@ format_line(wchar_t **wlinep, int *widthp, const char 
 			i++;
 			break;
 		default:
-			err = got_error_prefix_errno("wcwidth");
+			err = got_error_from_errno("wcwidth");
 			goto done;
 		}
 	}
@@ -900,7 +900,7 @@ build_refs_str(char **refs_str, struct got_reflist_hea
 		s = *refs_str;
 		if (asprintf(refs_str, "%s%s%s", s ? s : "",
 		    s ? ", " : "", name) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			free(s);
 			*refs_str = NULL;
 			break;
@@ -945,7 +945,7 @@ draw_commit(struct tog_view *view, struct got_commit_o
 
 	committer_time = got_object_commit_get_committer_time(commit);
 	if (localtime_r(&committer_time, &tm) == NULL)
-		return got_error_prefix_errno("localtime_r");
+		return got_error_from_errno("localtime_r");
 	if (strftime(datebuf, sizeof(datebuf), "%g/%m/%d ", &tm)
 	    >= sizeof(datebuf))
 		return got_error(GOT_ERR_NO_SPACE);
@@ -961,7 +961,7 @@ draw_commit(struct tog_view *view, struct got_commit_o
 
 	author = strdup(got_object_commit_get_author(commit));
 	if (author == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	err = format_author(&wauthor, &author_width, author, avail - col);
@@ -979,7 +979,7 @@ draw_commit(struct tog_view *view, struct got_commit_o
 
 	logmsg0 = strdup(got_object_commit_get_logmsg(commit));
 	if (logmsg0 == NULL) {
-		err = got_error_prefix_errno("strdup");
+		err = got_error_from_errno("strdup");
 		goto done;
 	}
 	logmsg = logmsg0;
@@ -1079,7 +1079,7 @@ queue_commits(struct got_commit_graph *graph, struct c
 			break;
 		entry = alloc_commit_queue_entry(commit, id);
 		if (entry == NULL) {
-			err = got_error_prefix_errno("alloc_commit_queue_entry");
+			err = got_error_from_errno("alloc_commit_queue_entry");
 			break;
 		}
 
@@ -1168,7 +1168,7 @@ draw_commits(struct tog_view *view, struct commit_queu
 	    entry ? entry->idx + 1 : 0, commits->ncommits,
 	    commits_needed > 0 ? "loading... " :
 	    (refs_str ? refs_str : "")) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -1176,14 +1176,14 @@ draw_commits(struct tog_view *view, struct commit_queu
 		if (asprintf(&header, "commit %s %s%s",
 		    id_str ? id_str : "........................................",
 		    path, ncommits_str) == -1) {
-			err = got_error_prefix_errno("asprintf");
+			err = got_error_from_errno("asprintf");
 			header = NULL;
 			goto done;
 		}
 	} else if (asprintf(&header, "commit %s%s",
 	    id_str ? id_str : "........................................",
 	    ncommits_str) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		header = NULL;
 		goto done;
 	}
@@ -1217,7 +1217,7 @@ draw_commits(struct tog_view *view, struct commit_queu
 			break;
 		author = strdup(got_object_commit_get_author(entry->commit));
 		if (author == NULL) {
-			err = got_error_prefix_errno("strdup");
+			err = got_error_from_errno("strdup");
 			goto done;
 		}
 		err = format_author(&wauthor, &width, author, COLS);
@@ -1375,7 +1375,7 @@ open_diff_view_for_commit(struct tog_view **new_view, 
 
 	diff_view = view_open(0, 0, 0, begin_x, TOG_VIEW_DIFF);
 	if (diff_view == NULL)
-		return got_error_prefix_errno("view_open");
+		return got_error_from_errno("view_open");
 
 	parent_id = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
 	err = open_diff_view(diff_view, parent_id ? parent_id->id : NULL,
@@ -1401,7 +1401,7 @@ browse_commit(struct tog_view **new_view, int begin_x,
 
 	tree_view = view_open(0, 0, 0, begin_x, TOG_VIEW_TREE);
 	if (tree_view == NULL)
-		return got_error_prefix_errno("view_open");
+		return got_error_from_errno("view_open");
 
 	err = open_tree_view(tree_view, tree, entry->id, refs, repo);
 	if (err)
@@ -1547,7 +1547,7 @@ open_log_view(struct tog_view *view, struct got_object
 	s->repo = repo;
 	s->start_id = got_object_id_dup(start_id);
 	if (s->start_id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 
@@ -1748,7 +1748,7 @@ input_log_view(struct tog_view **new_view, struct tog_
 			lv = view_open(view->nlines, view->ncols,
 			    view->begin_y, view->begin_x, TOG_VIEW_LOG);
 			if (lv == NULL)
-				return got_error_prefix_errno(
+				return got_error_from_errno(
 				    "view_open");
 			err = open_log_view(lv, s->start_id, s->refs,
 			    s->repo, parent_path, 0);
@@ -1776,20 +1776,20 @@ apply_unveil(const char *repo_path, const char *worktr
 	const struct got_error *error;
 
 	if (repo_path && unveil(repo_path, "r") != 0)
-		return got_error_prefix_errno2("unveil", repo_path);
+		return got_error_from_errno2("unveil", repo_path);
 
 	if (worktree_path && unveil(worktree_path, "rwc") != 0)
-		return got_error_prefix_errno2("unveil", worktree_path);
+		return got_error_from_errno2("unveil", worktree_path);
 
 	if (unveil("/tmp", "rwc") != 0)
-		return got_error_prefix_errno2("unveil", "/tmp");
+		return got_error_from_errno2("unveil", "/tmp");
 
 	error = got_privsep_unveil_exec_helpers();
 	if (error != NULL)
 		return error;
 
 	if (unveil(NULL, NULL) != 0)
-		return got_error_prefix_errno("unveil");
+		return got_error_from_errno("unveil");
 
 	return NULL;
 }
@@ -1850,7 +1850,7 @@ cmd_log(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	error = got_worktree_open(&worktree, cwd);
@@ -1861,7 +1861,7 @@ cmd_log(int argc, char *argv[])
 	if (argc == 0) {
 		path = strdup("");
 		if (path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else if (argc == 1) {
@@ -1873,7 +1873,7 @@ cmd_log(int argc, char *argv[])
 		} else {
 			path = strdup(argv[0]);
 			if (path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -1883,7 +1883,7 @@ cmd_log(int argc, char *argv[])
 	repo_path = worktree ?
 	    strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
 	if (repo_path == NULL) {
-		error = got_error_prefix_errno("strdup");
+		error = got_error_from_errno("strdup");
 		goto done;
 	}
 
@@ -1912,7 +1912,7 @@ cmd_log(int argc, char *argv[])
 
 	view = view_open(0, 0, 0, 0, TOG_VIEW_LOG);
 	if (view == NULL) {
-		error = got_error_prefix_errno("view_open");
+		error = got_error_from_errno("view_open");
 		goto done;
 	}
 	error = open_log_view(view, start_id, &refs, repo, path, 1);
@@ -2056,36 +2056,36 @@ write_commit_info(struct got_object_id *commit_id,
 
 	err = got_object_id_str(&id_str, commit_id);
 	if (err) {
-		err = got_error_prefix_errno("got_object_id_str");
+		err = got_error_from_errno("got_object_id_str");
 		goto done;
 	}
 
 	if (fprintf(outfile, "commit %s%s%s%s\n", id_str, refs_str ? " (" : "",
 	    refs_str ? refs_str : "", refs_str ? ")" : "") < 0) {
-		err = got_error_prefix_errno("fprintf");
+		err = got_error_from_errno("fprintf");
 		goto done;
 	}
 	if (fprintf(outfile, "from: %s\n",
 	    got_object_commit_get_author(commit)) < 0) {
-		err = got_error_prefix_errno("fprintf");
+		err = got_error_from_errno("fprintf");
 		goto done;
 	}
 	committer_time = got_object_commit_get_committer_time(commit);
 	if (fprintf(outfile, "date: %s UTC\n",
 	    get_datestr(&committer_time, datebuf)) < 0) {
-		err = got_error_prefix_errno("fprintf");
+		err = got_error_from_errno("fprintf");
 		goto done;
 	}
 	author = got_object_commit_get_author(commit);
 	committer = got_object_commit_get_committer(commit);
 	if (strcmp(author, committer) != 0 &&
 	    fprintf(outfile, "via: %s\n", committer) < 0) {
-		err = got_error_prefix_errno("fprintf");
+		err = got_error_from_errno("fprintf");
 		goto done;
 	}
 	if (fprintf(outfile, "%s\n",
 	    got_object_commit_get_logmsg(commit)) < 0) {
-		err = got_error_prefix_errno("fprintf");
+		err = got_error_from_errno("fprintf");
 		goto done;
 	}
 done:
@@ -2104,11 +2104,11 @@ create_diff(struct tog_diff_view_state *s)
 
 	f = got_opentemp();
 	if (f == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 	if (s->f && fclose(s->f) != 0) {
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 		goto done;
 	}
 	s->f = f;
@@ -2162,7 +2162,7 @@ create_diff(struct tog_diff_view_state *s)
 	}
 done:
 	if (f && fflush(f) != 0 && err == NULL)
-		err = got_error_prefix_errno("fflush");
+		err = got_error_from_errno("fflush");
 	return err;
 }
 
@@ -2198,7 +2198,7 @@ open_diff_view(struct tog_view *view, struct got_objec
 	if (id1) {
 		view->state.diff.id1 = got_object_id_dup(id1);
 		if (view->state.diff.id1 == NULL)
-			return got_error_prefix_errno("got_object_id_dup");
+			return got_error_from_errno("got_object_id_dup");
 	} else
 		view->state.diff.id1 = NULL;
 
@@ -2206,7 +2206,7 @@ open_diff_view(struct tog_view *view, struct got_objec
 	if (view->state.diff.id2 == NULL) {
 		free(view->state.diff.id1);
 		view->state.diff.id1 = NULL;
-		return got_error_prefix_errno("got_object_id_dup");
+		return got_error_from_errno("got_object_id_dup");
 	}
 	view->state.diff.f = NULL;
 	view->state.diff.first_displayed_line = 1;
@@ -2246,7 +2246,7 @@ close_diff_view(struct tog_view *view)
 	free(view->state.diff.id2);
 	view->state.diff.id2 = NULL;
 	if (view->state.diff.f && fclose(view->state.diff.f) == EOF)
-		err = got_error_prefix_errno("fclose");
+		err = got_error_from_errno("fclose");
 	return err;
 }
 
@@ -2268,7 +2268,7 @@ show_diff_view(struct tog_view *view)
 
 	if (asprintf(&header, "diff %s %s",
 	    id_str1 ? id_str1 : "/dev/null", id_str2) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		free(id_str1);
 		free(id_str2);
 		return err;
@@ -2293,7 +2293,7 @@ set_selected_commit(struct tog_diff_view_state *s,
 	free(s->id2);
 	s->id2 = got_object_id_dup(entry->id);
 	if (s->id2 == NULL)
-		return got_error_prefix_errno("got_object_id_dup");
+		return got_error_from_errno("got_object_id_dup");
 
 	err = got_object_open_as_commit(&selected_commit, s->repo, entry->id);
 	if (err)
@@ -2470,13 +2470,13 @@ cmd_diff(int argc, char *argv[])
 	} else if (argc == 2) {
 		repo_path = getcwd(NULL, 0);
 		if (repo_path == NULL)
-			return got_error_prefix_errno("getcwd");
+			return got_error_from_errno("getcwd");
 		id_str1 = argv[0];
 		id_str2 = argv[1];
 	} else if (argc == 3) {
 		repo_path = realpath(argv[0], NULL);
 		if (repo_path == NULL)
-			return got_error_prefix_errno2("realpath", argv[0]);
+			return got_error_from_errno2("realpath", argv[0]);
 		id_str1 = argv[1];
 		id_str2 = argv[2];
 	} else
@@ -2506,7 +2506,7 @@ cmd_diff(int argc, char *argv[])
 
 	view = view_open(0, 0, 0, 0, TOG_VIEW_DIFF);
 	if (view == NULL) {
-		error = got_error_prefix_errno("view_open");
+		error = got_error_from_errno("view_open");
 		goto done;
 	}
 	error = open_diff_view(view, id1, id2, NULL, &refs, repo);
@@ -2558,7 +2558,7 @@ draw_blame(struct tog_view *view, struct got_object_id
 	werase(view->window);
 
 	if (asprintf(&line, "commit %s", id_str) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		free(id_str);
 		return err;
 	}
@@ -2580,7 +2580,7 @@ draw_blame(struct tog_view *view, struct got_object_id
 	    *first_displayed_line - 1 + selected_line, nlines,
 	    blame_complete ? "" : "annotating... ", path) == -1) {
 		free(id_str);
-		return got_error_prefix_errno("asprintf");
+		return got_error_from_errno("asprintf");
 	}
 	free(id_str);
 	err = format_line(&wline, &width, line, view->ncols);
@@ -2686,7 +2686,7 @@ blame_cb(void *arg, int nlines, int lineno, struct got
 
 	line->id = got_object_id_dup(id);
 	if (line->id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 	line->annotated = 1;
@@ -2766,7 +2766,7 @@ stop_blame(struct tog_blame *blame)
 	}
 	if (blame->f) {
 		if (fclose(blame->f) != 0 && err == NULL)
-			err = got_error_prefix_errno("fclose");
+			err = got_error_from_errno("fclose");
 		blame->f = NULL;
 	}
 	if (blame->lines) {
@@ -2813,7 +2813,7 @@ run_blame(struct tog_blame *blame, struct tog_view *vi
 		goto done;
 	blame->f = got_opentemp();
 	if (blame->f == NULL) {
-		err = got_error_prefix_errno("got_opentemp");
+		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
 	err = got_object_blob_dump_to_file(&blame->filesize, &blame->nlines,
@@ -2823,7 +2823,7 @@ run_blame(struct tog_blame *blame, struct tog_view *vi
 
 	blame->lines = calloc(blame->nlines, sizeof(*blame->lines));
 	if (blame->lines == NULL) {
-		err = got_error_prefix_errno("calloc");
+		err = got_error_from_errno("calloc");
 		goto done;
 	}
 
@@ -2836,7 +2836,7 @@ run_blame(struct tog_blame *blame, struct tog_view *vi
 	blame->cb_args.nlines = blame->nlines;
 	blame->cb_args.commit_id = got_object_id_dup(commit_id);
 	if (blame->cb_args.commit_id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 	blame->cb_args.quit = done;
@@ -2877,7 +2877,7 @@ open_blame_view(struct tog_view *view, char *path,
 	s->blame_complete = 0;
 	s->path = path;
 	if (s->path == NULL)
-		return got_error_prefix_errno("open_blame_view");
+		return got_error_from_errno("open_blame_view");
 	s->repo = repo;
 	s->refs = refs;
 	s->commit_id = commit_id;
@@ -3086,7 +3086,7 @@ input_blame_view(struct tog_view **new_view, struct to
 		diff_view = view_open(0, 0, 0, begin_x, TOG_VIEW_DIFF);
 		if (diff_view == NULL) {
 			got_object_commit_close(commit);
-			err = got_error_prefix_errno("view_open");
+			err = got_error_from_errno("view_open");
 			break;
 		}
 		err = open_diff_view(diff_view, pid ? pid->id : NULL,
@@ -3194,7 +3194,7 @@ cmd_blame(int argc, char *argv[])
 
 	cwd = getcwd(NULL, 0);
 	if (cwd == NULL) {
-		error = got_error_prefix_errno("getcwd");
+		error = got_error_from_errno("getcwd");
 		goto done;
 	}
 	if (repo_path == NULL) {
@@ -3207,13 +3207,13 @@ cmd_blame(int argc, char *argv[])
 			repo_path =
 			    strdup(got_worktree_get_repo_path(worktree));
 			if (repo_path == NULL)
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 			if (error)
 				goto done;
 		} else {
 			repo_path = strdup(cwd);
 			if (repo_path == NULL) {
-				error = got_error_prefix_errno("strdup");
+				error = got_error_from_errno("strdup");
 				goto done;
 			}
 		}
@@ -3237,7 +3237,7 @@ cmd_blame(int argc, char *argv[])
 		    prefix, (strcmp(prefix, "/") != 0) ? "/" : "",
 		    worktree_subdir, worktree_subdir[0] ? "/" : "",
 		    path) == -1) {
-			error = got_error_prefix_errno("asprintf");
+			error = got_error_from_errno("asprintf");
 			goto done;
 		}
 		error = got_repo_map_path(&in_repo_path, repo, p, 0);
@@ -3268,7 +3268,7 @@ cmd_blame(int argc, char *argv[])
 
 	view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME);
 	if (view == NULL) {
-		error = got_error_prefix_errno("view_open");
+		error = got_error_from_errno("view_open");
 		goto done;
 	}
 	error = open_blame_view(view, in_repo_path, commit_id, &refs, repo);
@@ -3361,14 +3361,14 @@ draw_tree_entries(struct tog_view *view,
 		if (show_ids) {
 			err = got_object_id_str(&id_str, te->id);
 			if (err)
-				return got_error_prefix_errno(
+				return got_error_from_errno(
 				    "got_object_id_str");
 		}
 		if (asprintf(&line, "%s  %s%s", id_str ? id_str : "",
 		    te->name, S_ISDIR(te->mode) ? "/" :
 		    ((te->mode & S_IXUSR) ? "*" : "")) == -1) {
 			free(id_str);
-			return got_error_prefix_errno("asprintf");
+			return got_error_from_errno("asprintf");
 		}
 		free(id_str);
 		err = format_line(&wline, &width, line, view->ncols);
@@ -3469,7 +3469,7 @@ tree_entry_path(char **path, struct tog_parent_trees *
 
 	*path = calloc(1, len);
 	if (path == NULL)
-		return got_error_prefix_errno("calloc");
+		return got_error_from_errno("calloc");
 
 	(*path)[0] = '/';
 	pt = TAILQ_LAST(parents, tog_parent_trees);
@@ -3514,7 +3514,7 @@ blame_tree_entry(struct tog_view **new_view, int begin
 
 	blame_view = view_open(0, 0, 0, begin_x, TOG_VIEW_BLAME);
 	if (blame_view == NULL)
-		return got_error_prefix_errno("view_open");
+		return got_error_from_errno("view_open");
 
 	err = open_blame_view(blame_view, path, commit_id, refs, repo);
 	if (err) {
@@ -3537,7 +3537,7 @@ log_tree_entry(struct tog_view **new_view, int begin_x
 
 	log_view = view_open(0, 0, 0, begin_x, TOG_VIEW_LOG);
 	if (log_view == NULL)
-		return got_error_prefix_errno("view_open");
+		return got_error_from_errno("view_open");
 
 	err = tree_entry_path(&path, parents, te);
 	if (err)
@@ -3568,7 +3568,7 @@ open_tree_view(struct tog_view *view, struct got_tree_
 		goto done;
 
 	if (asprintf(&s->tree_label, "commit %s", commit_id_str) == -1) {
-		err = got_error_prefix_errno("asprintf");
+		err = got_error_from_errno("asprintf");
 		goto done;
 	}
 
@@ -3577,7 +3577,7 @@ open_tree_view(struct tog_view *view, struct got_tree_
 	s->first_displayed_entry = SIMPLEQ_FIRST(&s->entries->head);
 	s->commit_id = got_object_id_dup(commit_id);
 	if (s->commit_id == NULL) {
-		err = got_error_prefix_errno("got_object_id_dup");
+		err = got_error_from_errno("got_object_id_dup");
 		goto done;
 	}
 	s->refs = refs;
@@ -3758,7 +3758,7 @@ input_tree_view(struct tog_view **new_view, struct tog
 				break;
 			parent = calloc(1, sizeof(*parent));
 			if (parent == NULL) {
-				err = got_error_prefix_errno("calloc");
+				err = got_error_from_errno("calloc");
 				break;
 			}
 			parent->tree = s->tree;
@@ -3857,7 +3857,7 @@ cmd_tree(int argc, char *argv[])
 		struct got_worktree *worktree;
 		char *cwd = getcwd(NULL, 0);
 		if (cwd == NULL)
-			return got_error_prefix_errno("getcwd");
+			return got_error_from_errno("getcwd");
 		error = got_worktree_open(&worktree, cwd);
 		if (error && error->code != GOT_ERR_NOT_WORKTREE)
 			goto done;
@@ -3869,13 +3869,13 @@ cmd_tree(int argc, char *argv[])
 		} else
 			repo_path = cwd;
 		if (repo_path == NULL) {
-			error = got_error_prefix_errno("strdup");
+			error = got_error_from_errno("strdup");
 			goto done;
 		}
 	} else if (argc == 1) {
 		repo_path = realpath(argv[0], NULL);
 		if (repo_path == NULL)
-			return got_error_prefix_errno2("realpath", argv[0]);
+			return got_error_from_errno2("realpath", argv[0]);
 	} else
 		usage_log();
 
@@ -3912,7 +3912,7 @@ cmd_tree(int argc, char *argv[])
 
 	view = view_open(0, 0, 0, 0, TOG_VIEW_TREE);
 	if (view == NULL) {
-		error = got_error_prefix_errno("view_open");
+		error = got_error_from_errno("view_open");
 		goto done;
 	}
 	error = open_tree_view(view, tree, commit_id, &refs, repo);
@@ -4022,7 +4022,7 @@ main(int argc, char *argv[])
 				if (error == NULL)
 					got_repo_close(repo);
 			} else
-				error = got_error_prefix_errno2("realpath",
+				error = got_error_from_errno2("realpath",
 				    argv[0]);
 			if (error) {
 				if (hflag) {