commit - 06c44edcbf03f02d1d7c07f9360de526dd4203d3
commit + 0ae84acc1f0a0584e4f26ccbe029c895043b3abe
blob - 4820a2165e94f15daabdf5007b667947b46f6049
blob + 98f3281d5becb5173121e9f4f0b74eee3b61bebf
--- got/got.c
+++ got/got.c
struct got_pathlist_head ignores;
struct got_pathlist_entry *pe;
int preserve_logmsg = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&ignores);
error = get_gitconfig_path(&gitconfig_path);
if (error)
goto done;
- error = got_repo_open(&repo, repo_path, gitconfig_path);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, repo_path, gitconfig_path, pack_fds);
if (error)
goto done;
printf("Created branch %s with commit %s\n",
got_ref_get_name(branch_ref), id_str);
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
if (preserve_logmsg) {
fprintf(stderr, "%s: log message preserved in %s\n",
getprogname(), logmsg_path);
char *git_url = NULL;
int verbosity = 0, fetch_all_branches = 0, mirror_references = 0;
int list_refs_only = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&refs);
TAILQ_INIT(&symrefs);
error = got_repo_init(repo_path);
if (error)
goto done;
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
}
printf("Created %s repository '%s'\n",
mirror_references ? "mirrored" : "cloned", repo_path);
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
if (fetchpid > 0) {
if (kill(fetchpid, SIGTERM) == -1)
error = got_error_from_errno("kill");
struct got_fetch_progress_arg fpa;
int verbosity = 0, fetch_all_branches = 0, list_refs_only = 0;
int delete_refs = 0, replace_tags = 0, delete_remote = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&refs);
TAILQ_INIT(&symrefs);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &refs, entry) {
free((void *)pe->path);
free(pe->data);
int ch, same_path_prefix, allow_nonempty = 0, verbosity = 0;
struct got_pathlist_head paths;
struct got_checkout_progress_arg cpa;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
got_path_strip_trailing_slashes(repo_path);
got_path_strip_trailing_slashes(worktree_path);
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
if (error != NULL)
goto done;
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
+ if (error != NULL)
+ goto done;
+
/* Pre-create work tree path for unveil(2) */
error = got_path_mkdir(worktree_path);
if (error) {
if (cpa.had_base_commit_ref_error)
show_worktree_base_ref_warning();
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
if (head_ref)
got_ref_close(head_ref);
if (ref)
const struct got_error *err;
struct got_repository *repo;
static char msg[512];
+ int *pack_fds = NULL;
+
+ err = got_repo_pack_fds_open(&pack_fds);
+ if (err)
+ return err;
- err = got_repo_open(&repo, path, NULL);
+ err = got_repo_open(&repo, path, NULL, pack_fds);
if (err)
return orig_err;
"The got(1) manual page contains more information.", cmdname);
err = got_error_msg(GOT_ERR_NOT_WORKTREE, msg);
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (err == NULL)
+ err = pack_err;
+ }
return err;
}
struct got_pathlist_entry *pe;
int ch, verbosity = 0;
struct got_update_progress_arg upa;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, worktree_path);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
goto done;
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
got_worktree_get_head_ref_name(worktree), commit_id_str);
} else
printf("Already up-to-date\n");
+
print_update_progress_stats(&upa);
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(worktree_path);
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
struct got_reflist_head refs;
struct got_reflist_object_id_map *refs_idmap = NULL;
FILE *tmpfile = NULL;
+ int *pack_fds = NULL;
TAILQ_INIT(&refs);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
goto done;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
if (refs_idmap)
got_reflist_object_id_map_free(refs_idmap);
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
FILE *f1 = NULL, *f2 = NULL;
+ int *pack_fds = NULL;
TAILQ_INIT(&refs);
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
free(repo_path);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
struct blame_cb_args bca;
int ch, obj_type, i;
off_t filesize;
+ int *pack_fds = NULL;
memset(&bca, 0, sizeof(bca));
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
if (bca.lines) {
for (i = 0; i < bca.nlines; i++) {
struct blame_line *bline = &bca.lines[i];
char *commit_id_str = NULL;
int show_ids = 0, recurse = 0;
int ch;
+ int *pack_fds = NULL;
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
return error;
}
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
int ch, i, no_ignores = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
error = got_worktree_status(worktree, &paths, repo, no_ignores,
print_status, &st, check_cancelled, NULL);
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
+
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
int ch, do_list = 0, do_delete = 0, sort_by_time = 0;
const char *obj_arg = NULL, *symref_target= NULL;
char *refname = NULL;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "c:dr:ls:t")) != -1) {
switch (ch) {
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
free(repo_path);
return error;
struct got_pathlist_entry *pe;
struct got_object_id *commit_id = NULL;
char *commit_id_str = NULL;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
free(repo_path);
free(commit_id);
char *gitconfig_path = NULL, *tagger = NULL;
const char *tag_name, *commit_id_arg = NULL, *tagmsg = NULL;
int ch, do_list = 0;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "c:m:r:l")) != -1) {
switch (ch) {
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
got_worktree_close(worktree);
worktree = NULL;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
+
#ifndef PROFILE
/* Remove "cpath" promise. */
if (pledge("stdio rpath wpath flock proc exec sendfd unveil",
error = get_gitconfig_path(&gitconfig_path);
if (error)
goto done;
- error = got_repo_open(&repo, repo_path, gitconfig_path);
+ error = got_repo_open(&repo, repo_path, gitconfig_path,
+ pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
free(repo_path);
free(gitconfig_path);
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
int ch, can_recurse = 0, no_ignores = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
struct got_pathlist_entry *pe;
int ch, delete_local_mods = 0, can_recurse = 0, keep_on_disk = 0, i;
int ignore_missing_paths = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
char *cwd = NULL;
int ch, nop = 0, strip = -1, reverse = 0;
int patchfd;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "np:R")) != -1) {
switch (ch) {
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error != NULL)
goto done;
const char *repo_path = got_worktree_get_repo_path(worktree);
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_error;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
return error;
}
FILE *patch_script_file = NULL;
const char *patch_script_path = NULL;
struct choose_patch_arg cpa;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(path);
free(cwd);
return error;
int ch, rebase_in_progress, histedit_in_progress, preserve_logmsg = 0;
int allow_bad_symlinks = 0, non_interactive = 0, merge_in_progress = 0;
struct got_pathlist_head paths;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
cl_arg.logmsg_path = NULL;
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
if (error)
goto done;
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- gitconfig_path);
+ gitconfig_path, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
free(id_str);
free(gitconfig_path);
int verbosity = 0, overwrite_refs = 0;
int send_all_branches = 0, send_all_tags = 0;
struct got_reference *ref = NULL;
+ int *pack_fds = NULL;
TAILQ_INIT(&branches);
TAILQ_INIT(&tags);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
if (ref)
got_ref_close(ref);
got_pathlist_free(&branches);
struct got_object_qid *pid;
int ch;
struct got_update_progress_arg upa;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
+
return error;
}
struct got_object_qid *pid;
int ch;
struct got_update_progress_arg upa;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
return error;
}
const struct got_object_id_queue *parent_ids;
struct got_object_qid *qid, *pid;
struct got_update_progress_arg upa;
+ int *pack_fds = NULL;
STAILQ_INIT(&commits);
TAILQ_INIT(&merged_paths);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (list_backups || delete_backups) {
}
error = got_repo_open(&repo,
- worktree ? got_worktree_get_repo_path(worktree) : cwd, NULL);
+ worktree ? got_worktree_get_repo_path(worktree) : cwd, NULL,
+ pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
return error;
}
struct got_object_qid *pid;
struct got_histedit_list histedit_cmds;
struct got_histedit_list_entry *hle;
+ int *pack_fds = NULL;
STAILQ_INIT(&commits);
TAILQ_INIT(&histedit_cmds);
error = got_error_from_errno("getcwd");
goto done;
}
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (list_backups || delete_backups) {
if (list_backups || delete_backups) {
error = got_repo_open(&repo,
worktree ? got_worktree_get_repo_path(worktree) : cwd,
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
const struct got_error *close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ }
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
}
return error;
}
struct got_object_id *commit_id = NULL, *base_commit_id = NULL;
int ch;
struct got_update_progress_arg upa;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
goto done;
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(cwd);
free(base_commit_id);
free(commit_id);
struct got_update_progress_arg upa;
struct got_object_id *merge_commit_id = NULL;
char *branch_name = NULL;
+ int *pack_fds = NULL;
memset(&upa, 0, sizeof(upa));
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo,
- worktree ? got_worktree_get_repo_path(worktree) : cwd, NULL);
+ worktree ? got_worktree_get_repo_path(worktree) : cwd, NULL,
+ pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
return error;
}
FILE *patch_script_file = NULL;
const char *patch_script_path = NULL;
struct choose_patch_arg cpa;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
FILE *patch_script_file = NULL;
const char *patch_script_path = NULL;
struct choose_patch_arg cpa;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
error = got_repo_open(&repo, got_worktree_get_repo_path(worktree),
- NULL);
+ NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
struct got_commit_object *commit = NULL;
int ch, obj_type, i, force_path = 0;
struct got_reflist_head refs;
+ int *pack_fds = NULL;
TAILQ_INIT(&refs);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
return got_error_from_errno("strdup");
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
free(repo_path);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
+
got_ref_list_free(&refs);
return error;
}
struct got_pathlist_entry *pe;
char *uuidstr = NULL;
int ch, show_files = 0;
+ int *pack_fds = NULL;
TAILQ_INIT(&paths);
goto done;
}
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
}
}
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
TAILQ_FOREACH(pe, &paths, entry)
free((char *)pe->path);
got_pathlist_free(&paths);
blob - 59c11d1ab01684d8a2f16d934fb1d6870d7ac871
blob + d2e712fec877f56e6a3e85c0e93d10cc4ce1a702
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
int ch, npackfiles, npackedobj, nobj;
off_t packsize, loose_size;
char scaled[FMT_SCALED_STRSIZE];
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "r:")) != -1) {
switch (ch) {
if (error)
goto done;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
#ifndef PROFILE
done:
if (repo)
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
+
free(repo_path);
return error;
}
struct got_reflist_head exclude_refs;
struct got_reflist_head include_refs;
struct got_reflist_entry *re, *new;
+ int *pack_fds = NULL;
TAILQ_INIT(&exclude_args);
TAILQ_INIT(&exclude_refs);
if (error)
goto done;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
done:
if (repo)
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
got_pathlist_free(&exclude_args);
got_ref_list_free(&exclude_refs);
got_ref_list_free(&include_refs);
char *id_str = NULL;
struct got_pack_progress_arg ppa;
FILE *packfile = NULL;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
err(1, "pledge");
#endif
- error = got_repo_open(&repo, packfile_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, packfile_path, NULL, pack_fds);
if (error)
goto done;
done:
if (repo)
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(id_str);
free(pack_hash);
return error;
char *id_str, *delta_str = NULL, *base_id_str = NULL;
const char *type_str;
- err = got_object_id_str(&id_str, id);
+ err = got_object_id_str(&id_str, id);
if (err)
return err;
struct gotadmin_list_pack_cb_args lpa;
FILE *packfile = NULL;
int show_stats = 0, human_readable = 0;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "hs")) != -1) {
switch (ch) {
NULL) == -1)
err(1, "pledge");
#endif
- error = got_repo_open(&repo, packfile_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, packfile_path, NULL, pack_fds);
if (error)
goto done;
#ifndef PROFILE
done:
if (repo)
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(id_str);
free(pack_hash);
free(packfile_path);
char scaled_diff[FMT_SCALED_STRSIZE];
char **extensions;
int nextensions, i;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "apr:nq")) != -1) {
switch (ch) {
if (error)
goto done;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
done:
if (repo)
got_repo_close(repo);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(repo_path);
return error;
}
blob - 613976ee0e8a3f55e862ceb0aa730fd85f3e46e3
blob + 156fdc229cc2ed2c606d5aded919cc4fa7adeaad
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
enum kcgi_err kerr = KCGI_OK;
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil",
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
return error;
return got_error_from_errno("malloc");
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil",
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
goto done;
return got_error_from_errno("malloc");
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil",
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
NULL) == -1) {
error = got_error_from_errno("pledge");
goto done;
enum kcgi_err kerr = KCGI_OK;
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
+ NULL) == -1)
return got_error_from_errno("pledge");
#endif
error = gw_apply_unveil(gw_trans->gw_dir->path);
enum kcgi_err kerr = KCGI_OK;
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
+ NULL) == -1)
return got_error_from_errno("pledge");
#endif
if ((header = gw_init_header()) == NULL)
enum kcgi_err kerr = KCGI_OK;
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
+ NULL) == -1)
return got_error_from_errno("pledge");
#endif
if ((header = gw_init_header()) == NULL)
enum kcgi_err kerr = KCGI_OK;
#ifndef PROFILE
- if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil", NULL) == -1)
return got_error_from_errno("pledge");
#endif
if ((header = gw_init_header()) == NULL)
struct got_reflist_head refs;
struct got_reflist_entry *re;
time_t committer_time = 0, cmp_time = 0;
+ int *pack_fds = NULL;
*repo_age = NULL;
TAILQ_INIT(&refs);
if (gw_trans->repo)
repo = gw_trans->repo;
else {
- error = got_repo_open(&repo, dir, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&repo, dir, NULL, pack_fds);
if (error)
return error;
}
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
return error;
}
const struct got_error *error = NULL, *close_err;
struct got_repository *repo;
const char *gitconfig_owner;
+ int *pack_fds = NULL;
*owner = NULL;
if (gw_trans->gw_conf->got_show_repo_owner == 0)
return NULL;
- error = got_repo_open(&repo, dir, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ return error;
+ error = got_repo_open(&repo, dir, NULL, pack_fds);
if (error)
return error;
+
gitconfig_owner = got_repo_get_gitconfig_owner(repo);
if (gitconfig_owner) {
*owner = strdup(gitconfig_owner);
close_err = got_repo_close(repo);
if (error == NULL)
error = close_err;
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
return error;
}
char *in_repo_path = NULL;
struct got_object_id *id = NULL;
struct got_reference *ref;
+ int *pack_fds = NULL;
- error = got_repo_open(&gw_trans->repo, gw_trans->repo_path, NULL);
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+ error = got_repo_open(&gw_trans->repo, gw_trans->repo_path, NULL,
+ pack_fds);
if (error)
return error;
error = gw_get_commits(gw_trans, header, limit, id);
done:
- got_ref_list_free(&header->refs);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(id);
free(in_repo_path);
return error;
if (error)
goto done;
- if (gw_trans->action == GW_BLOB)
- error = gw_blob(gw_trans);
- else
- error = gw_display_index(gw_trans);
-done:
if (gw_trans->repo) {
const struct got_error *close_err;
close_err = got_repo_close(gw_trans->repo);
if (error == NULL)
error = close_err;
}
+ if (gw_trans->action == GW_BLOB)
+ error = gw_blob(gw_trans);
+ else
+ error = gw_display_index(gw_trans);
+done:
if (error) {
gw_trans->error = error;
gw_trans->action = GW_ERR;
blob - b6e44e8b40b8476a471c53fd10cffd4a7ff3b32d
blob + dea6dd81d267dfa92571a33f5c7559726bab8d8b
--- include/got_repository.h
+++ include/got_repository.h
/* Open and close repositories. */
const struct got_error *got_repo_open(struct got_repository**, const char *,
- const char *);
+ const char *, int *);
const struct got_error *got_repo_close(struct got_repository*);
/* Obtain the on-disk path to the repository. */
/* Obtain the number and size of packed objects in the repository. */
const struct got_error *got_repo_get_packfile_info(int *npackfiles,
int *nobjects, off_t *total_packsize, struct got_repository *);
+
+/* Create an array of file descriptors to hand over to got_repo_open for pack */
+const struct got_error *got_repo_pack_fds_open(int **);
+
+/* Close the array of file descriptors handed over to got_repo_open for pack */
+const struct got_error *got_repo_pack_fds_close(int *);
blob - a35884552cf66d678f0db623e1dd92d976a7014e
blob + 414cf45f495487020f948b4b0c3e6a45ef730da9
--- lib/got_lib_worktree.h
+++ lib/got_lib_worktree.h
struct got_object_id *base_commit_id;
char *head_ref_name;
uuid_t uuid;
+ int *pack_fds;
/*
* File descriptor for the lock file, open while a work tree is open.
blob - 5be66db732b6a51d032ae835a233ef3cbcd3733b
blob + a43b15276fae6a881257c7e298433f4256b081b0
--- lib/repository.c
+++ lib/repository.c
#define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
#endif
+#define GOT_PACK_NUM_TEMPFILES GOT_PACK_CACHE_SIZE * 2
+
RB_PROTOTYPE(got_packidx_bloom_filter_tree, got_packidx_bloom_filter, entry,
got_packidx_bloom_filter_cmp);
}
const struct got_error *
+got_repo_pack_fds_open(int **pack_fds)
+{
+ const struct got_error *err = NULL;
+ int i, pack_fds_tmp[GOT_PACK_NUM_TEMPFILES];
+
+ *pack_fds = calloc(GOT_PACK_NUM_TEMPFILES, sizeof(**pack_fds));
+ if (*pack_fds == NULL)
+ return got_error_from_errno("calloc");
+
+ for (i = 0; i < GOT_PACK_NUM_TEMPFILES; i++) {
+ pack_fds_tmp[i] = got_opentempfd();
+ if (pack_fds_tmp[i] == -1) {
+ err = got_repo_pack_fds_close(pack_fds_tmp);
+ if (err)
+ return err;
+ else
+ return got_error_from_errno("got_opentempfd");
+ }
+ }
+ memcpy(*pack_fds, pack_fds_tmp, sizeof(pack_fds_tmp));
+ return err;
+}
+
+const struct got_error *
+got_repo_pack_fds_close(int *pack_fds)
+{
+ const struct got_error *err = NULL;
+ int i;
+
+ for (i = 0; i < GOT_PACK_NUM_TEMPFILES; i++) {
+ if (pack_fds[i] == -1)
+ continue;
+ if (close(pack_fds[i]) == -1) {
+ err = got_error_from_errno("close");
+ break;
+ }
+ }
+ free(pack_fds);
+ pack_fds = NULL;
+ return err;
+}
+
+const struct got_error *
got_repo_cache_object(struct got_repository *repo, struct got_object_id *id,
struct got_object *obj)
{
const struct got_error *
got_repo_open(struct got_repository **repop, const char *path,
- const char *global_gitconfig_path)
+ const char *global_gitconfig_path, int *pack_fds)
{
struct got_repository *repo = NULL;
const struct got_error *err = NULL;
char *repo_path = NULL;
- size_t i;
+ size_t i, j = 0;
struct rlimit rl;
*repop = NULL;
repo->pack_cache_size = rl.rlim_cur / 8;
for (i = 0; i < nitems(repo->packs); i++) {
if (i < repo->pack_cache_size) {
- repo->packs[i].basefd = got_opentempfd();
- if (repo->packs[i].basefd == -1)
- return got_error_from_errno("got_opentempfd");
- repo->packs[i].accumfd = got_opentempfd();
- if (repo->packs[i].accumfd == -1)
- return got_error_from_errno("got_opentempfd");
+ repo->packs[i].basefd = pack_fds[j++];
+ repo->packs[i].accumfd = pack_fds[j++];
} else {
repo->packs[i].basefd = -1;
repo->packs[i].accumfd = -1;
free(bf);
}
- for (i = 0; i < repo->pack_cache_size; i++) {
+ for (i = 0; i < repo->pack_cache_size; i++)
if (repo->packs[i].path_packfile)
- got_pack_close(&repo->packs[i]);
- if (repo->packs[i].basefd != -1) {
- if (close(repo->packs[i].basefd) == -1 && err == NULL)
- err = got_error_from_errno("close");
- repo->packs[i].basefd = -1;
- }
- if (repo->packs[i].accumfd != -1) {
- if (close(repo->packs[i].accumfd) == -1 && err == NULL)
- err = got_error_from_errno("close");
- repo->packs[i].accumfd = -1;
- }
- }
+ if (repo->packs[i].path_packfile)
+ got_pack_close(&repo->packs[i]);
free(repo->path);
free(repo->path_git_dir);
blob - 673cbeb89c705904097774881d38ef9d51751939
blob + 8178c5fa66d216143d6c46befa61dc365b4afe68
--- lib/worktree_open.c
+++ lib/worktree_open.c
goto done;
}
- err = got_repo_open(&repo, (*worktree)->repo_path, NULL);
+ err = got_repo_pack_fds_open(&(*worktree)->pack_fds);
if (err)
goto done;
+ err = got_repo_open(&repo, (*worktree)->repo_path, NULL,
+ (*worktree)->pack_fds);
+ if (err)
+ goto done;
+
err = got_object_resolve_id_str(&(*worktree)->base_commit_id, repo,
base_commit_id_str);
if (err)
if (close(worktree->root_fd) == -1 && err == NULL)
err = got_error_from_errno2("close",
got_worktree_get_root_path(worktree));
+ if (worktree->pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(worktree->pack_fds);
+ if (err == NULL)
+ err = pack_err;
+ }
free(worktree->repo_path);
free(worktree->path_prefix);
free(worktree->base_commit_id);
blob - d0d583647fa722f8269697d6e94f89ef67153909
blob + 9018516f932ee548ec87c8bc079aee935759ede9
--- tog/tog.c
+++ tog/tog.c
struct tog_blame_thread_args thread_args;
struct tog_blame_cb_args cb_args;
const char *path;
+ int *pack_fds;
};
struct tog_blame_view_state {
}
TAILQ_INSERT_TAIL(&views, new_view, entry);
view = new_view;
- }
+ }
if (view) {
if (view_is_parent_view(view)) {
if (view->child && view->child->focussed)
struct got_repository *thread_repo = NULL;
struct got_commit_graph *thread_graph = NULL;
int errcode;
+ int *pack_fds = NULL;
if (in_repo_path != s->in_repo_path) {
free(s->in_repo_path);
view->search_start = search_start_log_view;
view->search_next = search_next_log_view;
- err = got_repo_open(&thread_repo, got_repo_get_path(repo), NULL);
+ err = got_repo_pack_fds_open(&pack_fds);
if (err)
goto done;
+ err = got_repo_open(&thread_repo, got_repo_get_path(repo), NULL,
+ pack_fds);
+ if (err)
+ goto done;
err = got_commit_graph_open(&thread_graph, s->in_repo_path,
!s->log_branches);
if (err)
s->thread_args.search_next_done = &view->search_next_done;
s->thread_args.regex = &view->regex;
done:
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (err == NULL)
+ err = pack_err;
+ }
if (err)
close_log_view(view);
return err;
struct tog_view *ref_view = NULL;
struct commit_queue_entry *entry;
int begin_x = 0, n, nscroll = view->nlines - 1;
+ int *pack_fds = NULL;
if (s->thread_args.load_all) {
if (ch == KEY_BACKSPACE)
} else /* 'B' */
s->log_branches = !s->log_branches;
+ err = got_repo_pack_fds_open(&pack_fds);
+ if (err)
+ return err;
err = got_repo_open(&s->thread_args.repo,
- got_repo_get_path(s->repo), NULL);
+ got_repo_get_path(s->repo), NULL, pack_fds);
+ if (err)
+ return err;
+ err = got_repo_pack_fds_close(pack_fds);
if (err)
return err;
tog_free_refs();
const char *head_ref_name = NULL;
int ch, log_branches = 0;
struct tog_view *view;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "bc:r:")) != -1) {
switch (ch) {
if (argc > 1)
usage_log();
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
cwd = getcwd(NULL, 0);
if (cwd == NULL)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
tog_free_refs();
return error;
}
int ch, force_text_diff = 0;
const char *errstr;
struct tog_view *view;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "aC:r:w")) != -1) {
switch (ch) {
} else
usage_diff();
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error)
+ goto done;
+
if (repo_path == NULL) {
cwd = getcwd(NULL, 0);
if (cwd == NULL)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error)
goto done;
}
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
tog_free_refs();
return error;
}
}
free(blame->cb_args.commit_id);
blame->cb_args.commit_id = NULL;
-
+ if (blame->pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(blame->pack_fds);
+ if (err == NULL)
+ err = pack_err;
+ }
return err;
}
struct got_repository *thread_repo = NULL;
struct got_object_id *obj_id = NULL;
int obj_type;
+ int *pack_fds = NULL;
err = got_object_open_as_commit(&commit, s->repo,
&s->blamed_commit->id);
goto done;
}
- err = got_repo_open(&thread_repo, got_repo_get_path(s->repo), NULL);
+ err = got_repo_pack_fds_open(&pack_fds);
if (err)
goto done;
+ err = got_repo_open(&thread_repo, got_repo_get_path(s->repo), NULL,
+ pack_fds);
+ if (err)
+ goto done;
+ blame->pack_fds = pack_fds;
blame->cb_args.view = view;
blame->cb_args.lines = blame->lines;
blame->cb_args.nlines = blame->nlines;
free(s->path);
free_colors(&s->colors);
-
return err;
}
char *commit_id_str = NULL;
int ch;
struct tog_view *view;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "c:r:")) != -1) {
switch (ch) {
if (argc != 1)
usage_blame();
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
if (repo_path == NULL) {
cwd = getcwd(NULL, 0);
if (cwd == NULL)
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
tog_free_refs();
return error;
}
const char *head_ref_name = NULL;
int ch;
struct tog_view *view;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "c:r:")) != -1) {
switch (ch) {
if (argc > 1)
usage_tree();
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
if (repo_path == NULL) {
cwd = getcwd(NULL, 0);
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
if (error == NULL)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
tog_free_refs();
return error;
}
char *cwd = NULL, *repo_path = NULL;
int ch;
struct tog_view *view;
+ int *pack_fds = NULL;
while ((ch = getopt(argc, argv, "r:")) != -1) {
switch (ch) {
if (argc > 1)
usage_ref();
+
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
if (repo_path == NULL) {
cwd = getcwd(NULL, 0);
}
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
if (close_err)
error = close_err;
}
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
tog_free_refs();
return error;
}
struct got_commit_object *commit = NULL;
char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL;
char *commit_id_str = NULL, **cmd_argv = NULL;
+ int *pack_fds = NULL;
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
+ error = got_repo_pack_fds_open(&pack_fds);
+ if (error != NULL)
+ goto done;
+
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
goto done;
}
- error = got_repo_open(&repo, repo_path, NULL);
+ error = got_repo_open(&repo, repo_path, NULL, pack_fds);
if (error != NULL)
goto done;
got_object_commit_close(commit);
if (worktree)
got_worktree_close(worktree);
+ if (pack_fds) {
+ const struct got_error *pack_err =
+ got_repo_pack_fds_close(pack_fds);
+ if (error == NULL)
+ error = pack_err;
+ }
free(id);
free(commit_id_str);
free(commit_id);