commit - 413628da33668e5776a08a6d61bddf02144c1ac6
commit + d6673cc02f85b0d8d581d344a659cf5ba8c93c0e
blob - 901d9542180b7cda62f567ffeaba04733fdcef91
blob + b8e1d37587798c64a9b4aa32a9e41a81d15c4cf3
--- cvg/cvg.c
+++ cvg/cvg.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
int preserve_logmsg = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&ignores);
+ RB_INIT(&ignores);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
* we have all required information.
*/
if (a->create_configs && !a->configs_created &&
- !TAILQ_EMPTY(a->config_info.symrefs)) {
+ !RB_EMPTY(a->config_info.symrefs)) {
err = create_config_files(a->config_info.proto,
a->config_info.host, a->config_info.port,
a->config_info.remote_repo_path,
const struct got_error *err;
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *refname = pe->path;
const char *targetref = pe->data;
printf("%s: %s\n", refname, targetref);
}
- TAILQ_FOREACH(pe, refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
char *id_str;
{
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
if (match_wanted_ref(refname, pe->path))
return 1;
}
char *branches = NULL, *refs = NULL;
ssize_t n;
- if (!fetch_all_branches && !TAILQ_EMPTY(wanted_branches)) {
+ if (!fetch_all_branches && !RB_EMPTY(wanted_branches)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
char *s;
branchname = pe->path;
if (strncmp(branchname, "refs/heads/", 11) == 0)
goto done;
}
}
- if (!TAILQ_EMPTY(wanted_refs)) {
+ if (!RB_EMPTY(wanted_refs)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
char *s;
const char *refname = pe->path;
if (strncmp(refname, "refs/", 5) == 0)
err = got_error_from_errno("asprintf");
goto done;
}
- } else if (!TAILQ_EMPTY(wanted_branches)) {
+ } else if (!RB_EMPTY(wanted_branches)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
char *s;
branchname = pe->path;
if (strncmp(branchname, "refs/heads/", 11) == 0)
goto done;
}
}
- if (!TAILQ_EMPTY(wanted_refs)) {
+ if (!RB_EMPTY(wanted_refs)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
char *s;
const char *refname = pe->path;
if (strncmp(refname, "refs/", 5) == 0)
* If we asked for a set of wanted branches then use the first
* one of those.
*/
- if (!TAILQ_EMPTY(wanted_branches)) {
- pe = TAILQ_FIRST(wanted_branches);
+ if (!RB_EMPTY(wanted_branches)) {
+ pe = RB_MIN(got_pathlist_head, wanted_branches);
default_branch = pe->path;
} else {
/* First HEAD ref listed by server is the default branch. */
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *refname = pe->path;
const char *target = pe->data;
int *pack_fds = NULL;
const char *jumphost = NULL;
- TAILQ_INIT(&refs);
- TAILQ_INIT(&symrefs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&refs);
+ RB_INIT(&symrefs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
while ((ch = getopt(argc, argv, "ab:J:lmqR:v")) != -1) {
switch (ch) {
argc -= optind;
argv += optind;
- if (fetch_all_branches && !TAILQ_EMPTY(&wanted_branches))
+ if (fetch_all_branches && !RB_EMPTY(&wanted_branches))
option_conflict('a', 'b');
if (list_refs_only) {
- if (!TAILQ_EMPTY(&wanted_branches))
+ if (!RB_EMPTY(&wanted_branches))
option_conflict('l', 'b');
if (fetch_all_branches)
option_conflict('l', 'a');
if (mirror_references)
option_conflict('l', 'm');
- if (!TAILQ_EMPTY(&wanted_refs))
+ if (!RB_EMPTY(&wanted_refs))
option_conflict('l', 'R');
}
free(id_str);
/* Set up references provided with the pack file. */
- TAILQ_FOREACH(pe, &refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
char *remote_refname;
}
/* Set the HEAD reference if the server provided one. */
- TAILQ_FOREACH(pe, &symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &symrefs) {
struct got_reference *target_ref;
const char *refname = pe->path;
const char *target = pe->data;
* a set of wanted branches use the first of one of those
* which could be fetched instead.
*/
- TAILQ_FOREACH(pe, &wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &wanted_branches) {
const char *target = pe->path;
struct got_reference *target_ref;
struct got_checkout_progress_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
struct got_reference *head_ref = NULL;
const char *jumphost = NULL;
- TAILQ_INIT(&paths);
- TAILQ_INIT(&refs);
- TAILQ_INIT(&symrefs);
+ RB_INIT(&paths);
+ RB_INIT(&refs);
+ RB_INIT(&symrefs);
TAILQ_INIT(&remote_refs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
while ((ch = getopt(argc, argv, "c:J:qr:vX")) != -1) {
switch (ch) {
}
/* Update references provided with the pack file. */
- TAILQ_FOREACH(pe, &refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
struct got_reference *ref;
*have_match = 0;
- TAILQ_FOREACH(pe, changed_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, changed_paths) {
if (regexec(regex, pe->path, 1, ®match, 0) == 0) {
*have_match = 1;
break;
if (header != NULL)
printf("%s\n", header);
- TAILQ_FOREACH(pe, dsa->paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, dsa->paths) {
struct got_diff_changed_path *cp = pe->data;
int pad = dsa->max_path_len - pe->path_len + 1;
if (changed_paths && diffstat == NULL) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, changed_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, changed_paths) {
struct got_diff_changed_path *cp = pe->data;
printf(" %c %s\n", cp->status, pe->path);
struct got_pathlist_head changed_paths;
STAILQ_INIT(&reversed_commits);
- TAILQ_INIT(&changed_paths);
+ RB_INIT(&changed_paths);
if (search_pattern && regcomp(®ex, search_pattern,
REG_EXTENDED | REG_NOSUB | REG_NEWLINE))
memset(&dsa, 0, sizeof(dsa));
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
- TAILQ_INIT(&diffstat_paths);
+ RB_INIT(&paths);
+ RB_INIT(&diffstat_paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
int ch, i, no_ignores = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
memset(&st, 0, sizeof(st));
st.status_codes = NULL;
int ch, can_recurse = 0, no_ignores = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
int ignore_missing_paths = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
if (a->commit_paths != NULL) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, a->commit_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, a->commit_paths) {
if (strncmp(path, pe->path,
pe->path_len) == 0) {
*a->has_changes = 1;
struct got_tree_object *tree = NULL, *ptree = NULL;
struct got_object_qid *pid;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
err = got_object_open_as_commit(&commit, repo, id);
if (err)
struct choose_patch_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
goto done;
}
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
dprintf(fd, "# %c %s\n",
got_commitable_get_status(ct),
int i;
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
cl_arg.logmsg_path = NULL;
#ifndef PROFILE
int found = 0;
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
err = got_ref_list(&refs, repo, NULL, got_ref_cmp_by_name, repo);
if (err)
* Clear error indication from any of the path arguments which
* would cause this file index entry to be displayed.
*/
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
if (got_path_cmp(path, pe->path, strlen(path),
pe->path_len) == 0 ||
got_path_is_child(path, pe->path, pe->path_len))
int ch, show_files = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (show_files) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (pe->path_len == 0)
continue;
/*
print_path_info, &paths, check_cancelled, NULL);
if (error)
goto done;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (pe->data != NULL) {
const struct got_error *perr;
blob - 211ce127da138b7f0ae6451335215737fabc1c1a
blob + 5db2fdbc49f5f220d6a5c3ca99d509315c111ce3
--- gitwrapper/gitwrapper.c
+++ gitwrapper/gitwrapper.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <sys/uio.h>
blob - e4de4f13cd3b5515003f3679b7e43ba94999ca4a
blob + 4f9a936005900e7b54a3fd696424a48a92a1d262
--- got/got.c
+++ got/got.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
int preserve_logmsg = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&ignores);
+ RB_INIT(&ignores);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
* we have all required information.
*/
if (a->create_configs && !a->configs_created &&
- !TAILQ_EMPTY(a->config_info.symrefs)) {
+ !RB_EMPTY(a->config_info.symrefs)) {
err = create_config_files(a->config_info.proto,
a->config_info.host, a->config_info.port,
a->config_info.remote_repo_path,
const struct got_error *err;
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *refname = pe->path;
const char *targetref = pe->data;
printf("%s: %s\n", refname, targetref);
}
- TAILQ_FOREACH(pe, refs, entry) {
+ RB_FOREACH(pe,got_pathlist_head, refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
char *id_str;
{
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
if (match_wanted_ref(refname, pe->path))
return 1;
}
char *branches = NULL, *refs = NULL;
ssize_t n;
- if (!fetch_all_branches && !TAILQ_EMPTY(wanted_branches)) {
+ if (!fetch_all_branches && !RB_EMPTY(wanted_branches)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
char *s;
branchname = pe->path;
if (strncmp(branchname, "refs/heads/", 11) == 0)
goto done;
}
}
- if (!TAILQ_EMPTY(wanted_refs)) {
+ if (!RB_EMPTY(wanted_refs)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
char *s;
const char *refname = pe->path;
if (strncmp(refname, "refs/", 5) == 0)
err = got_error_from_errno("asprintf");
goto done;
}
- } else if (!TAILQ_EMPTY(wanted_branches)) {
+ } else if (!RB_EMPTY(wanted_branches)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
char *s;
branchname = pe->path;
if (strncmp(branchname, "refs/heads/", 11) == 0)
goto done;
}
}
- if (!TAILQ_EMPTY(wanted_refs)) {
+ if (!RB_EMPTY(wanted_refs)) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
char *s;
const char *refname = pe->path;
if (strncmp(refname, "refs/", 5) == 0)
* If we asked for a set of wanted branches then use the first
* one of those.
*/
- if (!TAILQ_EMPTY(wanted_branches)) {
- pe = TAILQ_FIRST(wanted_branches);
+ if (!RB_EMPTY(wanted_branches)) {
+ pe = RB_MIN(got_pathlist_head, wanted_branches);
default_branch = pe->path;
} else {
/* First HEAD ref listed by server is the default branch. */
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *refname = pe->path;
const char *target = pe->data;
int bflag = 0, list_refs_only = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&refs);
- TAILQ_INIT(&symrefs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&refs);
+ RB_INIT(&symrefs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
while ((ch = getopt(argc, argv, "ab:J:lmqR:v")) != -1) {
switch (ch) {
argc -= optind;
argv += optind;
- if (fetch_all_branches && !TAILQ_EMPTY(&wanted_branches))
+ if (fetch_all_branches && !RB_EMPTY(&wanted_branches))
option_conflict('a', 'b');
if (list_refs_only) {
- if (!TAILQ_EMPTY(&wanted_branches))
+ if (!RB_EMPTY(&wanted_branches))
option_conflict('l', 'b');
if (fetch_all_branches)
option_conflict('l', 'a');
if (mirror_references)
option_conflict('l', 'm');
- if (!TAILQ_EMPTY(&wanted_refs))
+ if (!RB_EMPTY(&wanted_refs))
option_conflict('l', 'R');
}
free(id_str);
/* Set up references provided with the pack file. */
- TAILQ_FOREACH(pe, &refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
char *remote_refname;
}
/* Set the HEAD reference if the server provided one. */
- TAILQ_FOREACH(pe, &symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &symrefs) {
struct got_reference *target_ref;
const char *refname = pe->path;
const char *target = pe->data;
* a set of wanted branches use the first of one of those
* which could be fetched instead.
*/
- TAILQ_FOREACH(pe, &wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &wanted_branches) {
const char *target = pe->path;
struct got_reference *target_ref;
their_refname = local_refname;
}
- TAILQ_FOREACH(pe, their_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, their_refs) {
if (strcmp(their_refname, pe->path) == 0)
break;
}
if (pe != NULL)
continue;
- TAILQ_FOREACH(pe, their_symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, their_symrefs) {
if (strcmp(their_refname, pe->path) == 0)
break;
}
const char *remote_head = NULL, *worktree_branch = NULL;
const char *jumphost = NULL;
- TAILQ_INIT(&refs);
- TAILQ_INIT(&symrefs);
+ RB_INIT(&refs);
+ RB_INIT(&symrefs);
TAILQ_INIT(&remote_refs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
while ((ch = getopt(argc, argv, "ab:dJ:lqR:r:tvX")) != -1) {
switch (ch) {
argc -= optind;
argv += optind;
- if (fetch_all_branches && !TAILQ_EMPTY(&wanted_branches))
+ if (fetch_all_branches && !RB_EMPTY(&wanted_branches))
option_conflict('a', 'b');
if (list_refs_only) {
- if (!TAILQ_EMPTY(&wanted_branches))
+ if (!RB_EMPTY(&wanted_branches))
option_conflict('l', 'b');
if (fetch_all_branches)
option_conflict('l', 'a');
if (delete_remote) {
if (fetch_all_branches)
option_conflict('X', 'a');
- if (!TAILQ_EMPTY(&wanted_branches))
+ if (!RB_EMPTY(&wanted_branches))
option_conflict('X', 'b');
if (delete_refs)
option_conflict('X', 'd');
if (replace_tags)
option_conflict('X', 't');
- if (!TAILQ_EMPTY(&wanted_refs))
+ if (!RB_EMPTY(&wanted_refs))
option_conflict('X', 'R');
}
goto done;
}
- if (TAILQ_EMPTY(&wanted_branches)) {
+ if (RB_EMPTY(&wanted_branches)) {
if (!fetch_all_branches)
fetch_all_branches = remote->fetch_all_branches;
for (i = 0; i < remote->nfetch_branches; i++) {
goto done;
}
}
- if (TAILQ_EMPTY(&wanted_refs)) {
+ if (RB_EMPTY(&wanted_refs)) {
for (i = 0; i < remote->nfetch_refs; i++) {
error = got_pathlist_insert(NULL, &wanted_refs,
remote->fetch_refs[i], NULL);
}
/* Update references provided with the pack file. */
- TAILQ_FOREACH(pe, &refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
struct got_reference *ref;
if (!remote->mirror_references) {
/* Update remote HEAD reference if the server provided one. */
- TAILQ_FOREACH(pe, &symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &symrefs) {
struct got_reference *target_ref;
const char *refname = pe->path;
const char *target = pe->data;
struct got_checkout_progress_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
struct got_update_progress_arg upa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
if (branch_name) {
struct got_object_id *head_commit_id;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (pe->path_len == 0)
continue;
error = got_error_msg(GOT_ERR_BAD_PATH,
*have_match = 0;
- TAILQ_FOREACH(pe, changed_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, changed_paths) {
if (regexec(regex, pe->path, 1, ®match, 0) == 0) {
*have_match = 1;
break;
if (header != NULL)
printf("%s\n", header);
- TAILQ_FOREACH(pe, dsa->paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, dsa->paths) {
struct got_diff_changed_path *cp = pe->data;
int pad = dsa->max_path_len - pe->path_len + 1;
if (changed_paths && diffstat == NULL) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, changed_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, changed_paths) {
struct got_diff_changed_path *cp = pe->data;
printf(" %c %s\n", cp->status, pe->path);
struct got_pathlist_head changed_paths;
STAILQ_INIT(&reversed_commits);
- TAILQ_INIT(&changed_paths);
+ RB_INIT(&changed_paths);
if (search_pattern && regcomp(®ex, search_pattern,
REG_EXTENDED | REG_NOSUB | REG_NEWLINE))
memset(&dsa, 0, sizeof(dsa));
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
- TAILQ_INIT(&diffstat_paths);
+ RB_INIT(&paths);
+ RB_INIT(&diffstat_paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
int ch, i, no_ignores = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
memset(&st, 0, sizeof(st));
st.status_codes = NULL;
char *commit_id_str = NULL, *keyword_idstr = NULL;;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec "
int ch, can_recurse = 0, no_ignores = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
int ignore_missing_paths = 0;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
if (a->commit_paths != NULL) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, a->commit_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, a->commit_paths) {
if (strncmp(path, pe->path,
pe->path_len) == 0) {
*a->has_changes = 1;
struct got_tree_object *tree = NULL, *ptree = NULL;
struct got_object_qid *pid;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
err = got_object_open_as_commit(&commit, repo, id);
if (err)
struct choose_patch_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
if (!can_recurse) {
char *ondisk_path;
struct stat sb;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (asprintf(&ondisk_path, "%s/%s",
got_worktree_get_root_path(worktree),
pe->path) == -1) {
goto done;
}
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
dprintf(fd, "# %c %s\n",
got_commitable_get_status(ct),
int *pack_fds = NULL;
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
cl_arg.logmsg_path = NULL;
#ifndef PROFILE
if (success) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, a->delete_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, a->delete_branches) {
const char *branchname = pe->path;
if (got_path_cmp(branchname, refname,
strlen(branchname), strlen(refname)) == 0) {
int *pack_fds = NULL;
const char *jumphost = NULL;
- TAILQ_INIT(&branches);
- TAILQ_INIT(&tags);
+ RB_INIT(&branches);
+ RB_INIT(&tags);
TAILQ_INIT(&all_branches);
TAILQ_INIT(&all_tags);
- TAILQ_INIT(&delete_args);
- TAILQ_INIT(&delete_branches);
+ RB_INIT(&delete_args);
+ RB_INIT(&delete_branches);
while ((ch = getopt(argc, argv, "ab:d:fJ:qr:Tt:v")) != -1) {
switch (ch) {
argc -= optind;
argv += optind;
- if (send_all_branches && !TAILQ_EMPTY(&branches))
+ if (send_all_branches && !RB_EMPTY(&branches))
option_conflict('a', 'b');
- if (send_all_tags && !TAILQ_EMPTY(&tags))
+ if (send_all_tags && !RB_EMPTY(&tags))
option_conflict('T', 't');
* with 'got send -d'.
* Deleting anything else requires local repository access or Git.
*/
- TAILQ_FOREACH(pe, &delete_args, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &delete_args) {
const char *branchname = pe->path;
char *s;
struct got_pathlist_entry *new;
int found = 0;
TAILQ_INIT(&refs);
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
err = got_ref_list(&refs, repo, NULL, got_ref_cmp_by_name, repo);
if (err)
int *pack_fds = NULL;
STAILQ_INIT(&commits);
- TAILQ_INIT(&merged_paths);
+ RB_INIT(&merged_paths);
memset(&upa, 0, sizeof(upa));
#ifndef PROFILE
branch_head_commit_id);
if (error)
goto done;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
STAILQ_INIT(&commits);
TAILQ_INIT(&histedit_cmds);
- TAILQ_INIT(&merged_paths);
+ RB_INIT(&merged_paths);
memset(&upa, 0, sizeof(upa));
#ifndef PROFILE
struct got_pathlist_head paths;
int have_changes = 0;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
branch_tip);
if (error)
goto done;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
struct choose_patch_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
struct choose_patch_arg cpa;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec sendfd "
* Clear error indication from any of the path arguments which
* would cause this file index entry to be displayed.
*/
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
if (got_path_cmp(path, pe->path, strlen(path),
pe->path_len) == 0 ||
got_path_is_child(path, pe->path, pe->path_len))
int *pack_fds = NULL;
int ch, show_files = 0;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
if (show_files) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (pe->path_len == 0)
continue;
/*
print_path_info, &paths, check_cancelled, NULL);
if (error)
goto done;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
if (pe->data != NULL) {
const struct got_error *perr;
blob - b4498d7b27edc861c011a977cef6c8b66603f09d
blob + 5a8c2bc8ec21628c9260de98ee4077f5f878ff15
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <ctype.h>
struct got_reflist_entry *re, *new;
int *pack_fds = NULL;
- TAILQ_INIT(&exclude_args);
+ RB_INIT(&exclude_args);
TAILQ_INIT(&exclude_refs);
TAILQ_INIT(&include_refs);
if (error)
goto done;
- TAILQ_FOREACH(pe, &exclude_args, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &exclude_args) {
const char *refname = pe->path;
error = add_ref(&new, &exclude_refs, refname, repo);
if (error)
int verbosity = 0;
int i, ch;
- TAILQ_INIT(&exclude_args);
+ RB_INIT(&exclude_args);
TAILQ_INIT(&exclude_refs);
TAILQ_INIT(&include_refs);
if (error)
goto done;
- TAILQ_FOREACH(pe, &exclude_args, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &exclude_args) {
refname = pe->path;
error = add_ref(&new, &exclude_refs, refname, repo);
if (error)
{
struct got_pathlist_entry *pe;
- if (TAILQ_EMPTY(wanted))
+ if (RB_EMPTY(wanted))
return 1;
- TAILQ_FOREACH(pe, wanted, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted) {
if (strcmp(pe->path, ref) == 0)
return 1;
}
int verbosity = 0;
int ch, i;
- TAILQ_INIT(&include_args);
- TAILQ_INIT(&available_refs);
+ RB_INIT(&include_args);
+ RB_INIT(&available_refs);
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath fattr flock proc exec "
goto done;
if (list_refs_only) {
- TAILQ_FOREACH(pe, &available_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &available_refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
char *idstr;
goto done;
/* Update references */
- TAILQ_FOREACH(pe, &available_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &available_refs) {
const struct got_error *unlock_err;
struct got_reference *ref;
const char *refname = pe->path;
blob - 8eb6f4396784abfa7a956c90fb3cc41e5d2b433f
blob + 8b82d1907770f8ead09033b724fa42de69e518be
--- gotctl/gotctl.c
+++ gotctl/gotctl.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <sys/un.h>
blob - 41f6842f800bb0722d2303a4924d74865b6d1fba
blob + 8d274e36aa1f7805cbd23da72ff2b38109621dea
--- gotd/auth.c
+++ gotd/auth.c
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <errno.h>
blob - d0c3603547caa4335b08553a55a7113dfc613d21
blob + 8993f7756e9028f8ef050eefe400427e6566a59b
--- gotd/imsg.c
+++ gotd/imsg.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <sys/uio.h>
blob - 5dab7072d9c805c4247a01452c85875d4639f46e
blob + 28fbaa765410499bebb4c75973c46de6655912a1
--- gotd/listen.c
+++ gotd/listen.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <sys/uio.h>
blob - b48a3fe7e6a07d8747d390f34683097289a4d6c2
blob + dd67229618c65cd823858180377b61bd8b02830e
--- gotd/parse.y
+++ gotd/parse.y
#include <sys/time.h>
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <ctype.h>
fatalx("%s: calloc", __func__);
STAILQ_INIT(&repo->rules);
- TAILQ_INIT(&repo->protected_tag_namespaces);
- TAILQ_INIT(&repo->protected_branch_namespaces);
- TAILQ_INIT(&repo->protected_branches);
- TAILQ_INIT(&repo->protected_branches);
- TAILQ_INIT(&repo->notification_refs);
- TAILQ_INIT(&repo->notification_ref_namespaces);
+ RB_INIT(&repo->protected_tag_namespaces);
+ RB_INIT(&repo->protected_branch_namespaces);
+ RB_INIT(&repo->protected_branches);
+ RB_INIT(&repo->protected_branches);
+ RB_INIT(&repo->notification_refs);
+ RB_INIT(&repo->notification_ref_namespaces);
STAILQ_INIT(&repo->notification_targets);
if (strlcpy(repo->name, name, sizeof(repo->name)) >=
namespace) == -1)
return -1;
- TAILQ_FOREACH(pe, &repo->protected_branch_namespaces, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->protected_branch_namespaces) {
if (strcmp(pe->path, new) == 0) {
yyerror("duplicate protected namespace %s", namespace);
return -1;
&repo->protected_branch_namespaces, namespace) == -1)
return -1;
- TAILQ_FOREACH(pe, &repo->protected_tag_namespaces, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->protected_tag_namespaces) {
if (strcmp(pe->path, new) == 0) {
yyerror("duplicate protected namespace %s", namespace);
return -1;
blob - 77b067240f937a51ae13c32d0bbc9362d7796286
blob + cde254c906d136723be9be3524aa383c26132dad
--- gotd/repo_imsg.c
+++ gotd/repo_imsg.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <event.h>
blob - f44eb26f2a6197c25f2795391a684fce6ef79b29
blob + 62e95bc3c4eee3e045d642b2b1a6496f839d03ce
--- gotd/repo_read.c
+++ gotd/repo_read.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <event.h>
blob - 00881c209db0d54b36e0c566e676b5446387618e
blob + 8f92913331bd60b19ef2fd111b33c55e075f4a01
--- gotd/repo_write.c
+++ gotd/repo_write.c
if (ref_update->delete_ref)
continue;
- TAILQ_FOREACH(pe, repo_write.protected_tag_namespaces, entry) {
+ RB_FOREACH(pe, got_pathlist_head, repo_write.protected_tag_namespaces) {
err = protect_tag_namespace(pe->path, &client->pack,
packidx, ref_update);
if (err)
}
}
- TAILQ_FOREACH(pe, repo_write.protected_branch_namespaces,
- entry) {
+ RB_FOREACH(pe, got_pathlist_head, repo_write.protected_branch_namespaces)
+ {
err = protect_branch_namespace(pe->path,
&client->pack, packidx, ref_update);
if (err)
goto done;
}
- TAILQ_FOREACH(pe, repo_write.protected_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, repo_write.protected_branches)
+ {
err = protect_branch(pe->path, &client->pack,
packidx, ref_update);
if (err)
refname = got_ref_get_name(ref_update->ref);
- TAILQ_FOREACH(pe, repo_write.protected_tag_namespaces, entry) {
+ RB_FOREACH(pe, got_pathlist_head,
+ repo_write.protected_tag_namespaces) {
err = protect_ref_namespace(refname, pe->path);
if (err)
return err;
}
- TAILQ_FOREACH(pe, repo_write.protected_branch_namespaces,
- entry) {
+ RB_FOREACH(pe, got_pathlist_head,
+ repo_write.protected_branch_namespaces) {
err = protect_ref_namespace(refname, pe->path);
if (err)
return err;
}
- TAILQ_FOREACH(pe, repo_write.protected_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, repo_write.protected_branches)
+ {
if (strcmp(refname, pe->path) == 0) {
return got_error_fmt(GOT_ERR_REF_PROTECTED,
"%s", refname);
{
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, dsa->paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, dsa->paths) {
struct got_diff_changed_path *cp = pe->data;
int pad = dsa->max_path_len - pe->path_len + 1;
const int shortlog_threshold = 50;
STAILQ_INIT(&reversed_commits);
- TAILQ_INIT(&changed_paths);
+ RB_INIT(&changed_paths);
/* XXX first-parent only for now */
err = got_commit_graph_open(&graph, "/", 1);
blob - ce6a68ae4e3613742b57a1c5fafd1978318f2ff5
blob + 1c759a341683fe39614e0c779362809c3d1610e2
--- gotd/session_write.c
+++ gotd/session_write.c
STAILQ_EMPTY(&repo_cfg->notification_targets))
return NULL; /* notifications unused */
- TAILQ_FOREACH(pe, &repo_cfg->notification_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo_cfg->notification_refs) {
const char *refname = pe->path;
if (strcmp(got_ref_get_name(ref), refname) == 0)
break;
}
if (pe == NULL) {
- TAILQ_FOREACH(pe, &repo_cfg->notification_ref_namespaces,
- entry) {
+ RB_FOREACH(pe, got_pathlist_head,
+ &repo_cfg->notification_ref_namespaces) {
const char *namespace = pe->path;
err = validate_namespace(namespace);
* configuration file then only send notifications if a match
* was found.
*/
- if (pe == NULL && (!TAILQ_EMPTY(&repo_cfg->notification_refs) ||
- !TAILQ_EMPTY(&repo_cfg->notification_ref_namespaces)))
+ if (pe == NULL && (!RB_EMPTY(&repo_cfg->notification_refs) ||
+ !RB_EMPTY(&repo_cfg->notification_ref_namespaces)))
return NULL;
notif = calloc(1, sizeof(*notif));
blob - c578f8cbb9a1c2672039a719cdba04b4eacdb8d9
blob + 13623bc34739f85f1e1611827992c048d0747d09
--- gotsh/gotsh.c
+++ gotsh/gotsh.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <sys/un.h>
blob - fa0ac810a87d9612d80f8ec79b2bd02e05585ee4
blob + 2a9b146bfbe9dc3e2c817db363f23b0f026365e2
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <sys/stat.h>
blob - 358f228a50594aeabb3309b1319deec29ce35311
blob + 1a1a8770b26108d09399eb43a781fa0e4d63c1b9
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
#include <net/if.h>
#include <netinet/in.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <sys/types.h>
blob - 1100e919033e225f9500e38d04dc8c9304369742
blob + 8232df1c967a331ed394daaa474c7547e2c93fda
--- include/got_path.h
+++ include/got_path.h
*/
int got_path_cmp(const char *, const char *, size_t, size_t);
-/*
- * Path lists allow for predictable concurrent iteration over multiple lists
- * of paths obtained from disparate sources which don't all provide the same
- * ordering guarantees (e.g. git trees, file index, and on-disk directories).
- */
+
struct got_pathlist_entry {
- TAILQ_ENTRY(got_pathlist_entry) entry;
+ RB_ENTRY(got_pathlist_entry) entry;
const char *path;
size_t path_len;
void *data; /* data pointer provided to got_pathlist_insert() */
};
-TAILQ_HEAD(got_pathlist_head, got_pathlist_entry);
+int got_pathlist_cmp(const struct got_pathlist_entry * , const struct got_pathlist_entry *);
+RB_HEAD(got_pathlist_head, got_pathlist_entry);
+RB_PROTOTYPE(got_pathlist_head, got_pathlist_entry, entry, got_pathlist_cmp);
+
/*
* Insert a path into the list of paths in a predictable order.
* The caller should already have initialized the list head. This list stores
blob - 1efd31bd7fbba8901c47aba134f6e6aa7381e4f5
blob + 520585806a2fff0f856abd6880e5c48cbacd6069
--- lib/commit_graph.c
+++ lib/commit_graph.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stdint.h>
#include <limits.h>
blob - 11a24fdcbb22ef869c3b17bf02354c6f7a580e97
blob + 5ee4248318a070e5605e27ad3ee7e408896a2ce8
--- lib/deflate.c
+++ lib/deflate.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <errno.h>
#include <stdio.h>
blob - e43d98ae41c70e48398afaded344bc66a394b968
blob + 2c3f8c2ebcd41b76c90f5701a0b1ffc43fbdccc3
--- lib/delta.c
+++ lib/delta.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <stdio.h>
#include <stdlib.h>
blob - 6f47d70612b97fe473d6aba91f3907153a33dd56
blob + ca330996f861e3db0b6d6182071f7f81bb4b4144
--- lib/dial.c
+++ lib/dial.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
blob - 705da341e0ac7d7a3ac8291c8c6ad8d46b365aee
blob + 658c27563232e250780c4d2b9306e9643b58167f
--- lib/diff.c
+++ lib/diff.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <stdio.h>
return err;
}
- pe = TAILQ_LAST(ds->paths, got_pathlist_head);
+ pe = RB_MAX(got_pathlist_head, ds->paths);
diffstat_field_width(&ds->max_path_len, &ds->add_cols, &ds->rm_cols,
pe->path_len, change->add, change->rm);
struct got_tree_object *subtree1 = NULL, *subtree2 = NULL;
struct got_blob_object *blob1 = NULL, *blob2 = NULL;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
int type1 = GOT_OBJ_TYPE_ANY, type2 = GOT_OBJ_TYPE_ANY;
mode_t mode1 = 0, mode2 = 0;
arg.lines = NULL;
arg.nlines = 0;
}
- if (paths == NULL || TAILQ_EMPTY(paths))
+ if (paths == NULL || RB_EMPTY(paths))
err = got_diff_tree(tree1, tree2, f1, f2, fd1, fd2, label1,
label2, repo, got_diff_blob_output_unidiff, &arg, 1);
else
blob - b64070e012cce8f1a3fb519298edb01b361b48eb
blob + 4e0331d997a587a82491c0c1835d0ae523400561
--- lib/fetch.c
+++ lib/fetch.c
* Prevent fetching of references that won't make any
* sense outside of the remote repository's context.
*/
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
const char *refname = pe->path;
if (strncmp(refname, "refs/got/", 9) == 0 ||
strncmp(refname, "got/", 4) == 0 ||
for (i = 0; i < nitems(tmpfds); i++)
tmpfds[i] = -1;
- TAILQ_INIT(&have_refs);
+ RB_INIT(&have_refs);
TAILQ_INIT(&my_refs);
if (!list_refs_only) {
blob - 6ddd929ab113d775d617c28c07573f2012ec924c
blob + dbef298e12a03f1a40e8adf8a5cffe916aca0681
--- lib/fileindex.c
+++ lib/fileindex.c
static const struct got_error *
walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
- struct got_fileindex_entry **ie, struct got_pathlist_entry *dle, int fd,
- const char *path, const char *rootpath, struct got_repository *repo,
- int ignore, struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
+ struct got_fileindex_entry **ie, struct got_pathlist_entry *dle,
+ struct got_pathlist_head *dlh, int fd, const char *path,
+ const char *rootpath, struct got_repository *repo, int ignore,
+ struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
{
const struct got_error *err = NULL;
struct dirent *de = dle->data;
char *subdirpath;
struct got_pathlist_head subdirlist;
- TAILQ_INIT(&subdirlist);
+ RB_INIT(&subdirlist);
if (asprintf(&subpath, "%s%s%s", path,
path[0] == '\0' ? "" : "/", de->d_name) == -1)
O_RDONLY | O_NOFOLLOW | O_DIRECTORY | O_CLOEXEC);
if (subdirfd == -1) {
if (errno == EACCES) {
- *next = TAILQ_NEXT(dle, entry);
+ *next = RB_NEXT(got_pathlist_head, dlh, dle);
return NULL;
}
err = got_error_from_errno2("openat", subdirpath);
return err;
}
- *next = TAILQ_NEXT(dle, entry);
+ *next = RB_NEXT(got_pathlist_head, dlh, dle);
return NULL;
}
return err;
}
- dle = TAILQ_FIRST(dirlist);
+ dle = RB_MIN(got_pathlist_head, dirlist);
while ((*ie && got_path_is_child((*ie)->path, path, path_len)) || dle) {
if (dle && *ie) {
char *de_path;
if (err)
break;
*ie = walk_fileindex(fileindex, *ie);
- err = walk_dir(&dle, fileindex, ie, dle, dirfd,
- path, rootpath, repo, 0, cb, cb_arg);
- } else if (cmp < 0 ) {
+ err = walk_dir(&dle, fileindex, ie, dle,
+ dirlist, dirfd, path, rootpath, repo, 0,
+ cb, cb_arg);
+ } else if (cmp < 0) {
err = cb->diff_old(cb_arg, *ie, path);
if (err)
break;
dirfd);
if (err)
break;
- err = walk_dir(&dle, fileindex, ie, dle, dirfd,
- path, rootpath, repo, ignore, cb, cb_arg);
+ err = walk_dir(&dle, fileindex, ie, dle,
+ dirlist, dirfd, path, rootpath, repo,
+ ignore, cb, cb_arg);
}
if (err)
break;
err = cb->diff_new(&ignore, cb_arg, de, path, dirfd);
if (err)
break;
- err = walk_dir(&dle, fileindex, ie, dle, dirfd, path,
- rootpath, repo, ignore, cb, cb_arg);
+ err = walk_dir(&dle, fileindex, ie, dle, dirlist,
+ dirfd, path, rootpath, repo, ignore, cb, cb_arg);
if (err)
break;
}
int fd2;
DIR *dir;
- TAILQ_INIT(&dirlist);
+ RB_INIT(&dirlist);
/*
* Duplicate the file descriptor so we can call closedir() below
blob - 7bf09a8a6503e2cf488f090ab7a98b0a0762ae04
blob + f8a58e05685c1a15956029d0833c3014e3008d78
--- lib/gitproto.c
+++ lib/gitproto.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/types.h>
#include <ctype.h>
blob - e8f06f56c03a04d123c91c39f96c6bc046cb71d9
blob + 49f05411c2efb58063883962301c09d2319d19e6
--- lib/inflate.c
+++ lib/inflate.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <errno.h>
#include <stdio.h>
blob - 0af419be5282778934e8a5369c5793756c35ecd3
blob + 8a796d4d28606f8e51d7207a19b3cb470facba06
--- lib/lockfile.c
+++ lib/lockfile.c
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <errno.h>
#include <fcntl.h>
blob - c3f64cf304de14ee32b20d2d42f888f38bec81a0
blob + 9d98158fc39b736def37140f6711f0da05badf51
--- lib/object_create.c
+++ lib/object_create.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/wait.h>
#include <ctype.h>
return got_error_from_errno("calloc");
i = 0;
- TAILQ_FOREACH(pe, paths, entry)
+ RB_FOREACH(pe, got_pathlist_head, paths)
sorted_entries[i++] = pe->data;
mergesort(sorted_entries, nentries, sizeof(struct got_tree_entry *),
sort_tree_entries_the_way_git_likes_it);
blob - 5b83d584098fac8855f9938cbe05d3425d7c6bde
blob + ed36f2076d71d7ed6931ebfd54eac2aa82fc6264
--- lib/pack.c
+++ lib/pack.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/mman.h>
#include <sys/resource.h>
blob - 51eb2fd9f78c26e8b8bdecf029482685172ecfe7
blob + c6787c3643ca1ced91d4ef5d2530f153f72bb6e0
--- lib/pack_create.c
+++ lib/pack_create.c
*best_packidx = NULL;
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
const char *path_packidx = pe->path;
struct got_packidx *packidx;
int nobj;
* Find the largest pack which contains at least some of the
* commits we are interested in.
*/
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
const char *path_packidx = pe->path;
struct got_packidx *packidx;
int nobj, idx, ncommits = 0;
* Find the largest pack which contains at least some of the
* commits and tags we are interested in.
*/
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
const char *path_packidx = pe->path;
struct got_packidx *packidx;
int nobj, i, idx, ncommits = 0;
blob - 0e7c4171ee06743bd3b8004b3c0b3158aa3118da
blob + 1e2281754794ae39f794df658cc348bd6aaf1490
--- lib/patch.c
+++ lib/patch.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/uio.h>
blob - 8242bbe0f1553766e05f3b6750c7a283387e0907
blob + 19b5fc1b23828a64e772094208f1a08e0372df5a
--- lib/path.c
+++ lib/path.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <errno.h>
return (unsigned char)path1[i] < (unsigned char)path2[i] ? -1 : 1;
}
+int
+got_pathlist_cmp(const struct got_pathlist_entry *p1,
+ const struct got_pathlist_entry *p2)
+{
+ return got_path_cmp(p1->path, p2->path, p1->path_len, p2->path_len);
+}
+
const struct got_error *
got_pathlist_insert(struct got_pathlist_entry **inserted,
struct got_pathlist_head *pathlist, const char *path, void *data)
{
- struct got_pathlist_entry *new, *pe;
+ struct got_pathlist_entry *new;
size_t path_len = strlen(path);
if (inserted)
*inserted = NULL;
-
- /*
- * Many callers will provide paths in a somewhat sorted order while
- * constructing a path list from inputs such as tree objects or
- * dirents. Iterating backwards from the tail of the list should
- * be more efficient than traversing through the entire list each
- * time an element is inserted.
- */
- pe = TAILQ_LAST(pathlist, got_pathlist_head);
- while (pe) {
- int cmp = got_path_cmp(pe->path, path, pe->path_len, path_len);
- if (cmp == 0)
- return NULL; /* duplicate */
- else if (cmp < 0)
- break;
- pe = TAILQ_PREV(pe, got_pathlist_head, entry);
- }
-
new = malloc(sizeof(*new));
if (new == NULL)
return got_error_from_errno("malloc");
new->path = path;
new->path_len = path_len;
new->data = data;
- if (pe)
- TAILQ_INSERT_AFTER(pathlist, pe, new, entry);
- else
- TAILQ_INSERT_HEAD(pathlist, new, entry);
+ RB_INSERT(got_pathlist_head, pathlist, new);
if (inserted)
*inserted = new;
return NULL;
void
got_pathlist_free(struct got_pathlist_head *pathlist, int freemask)
{
- struct got_pathlist_entry *pe;
+ struct got_pathlist_entry *pe, *temp;
- while ((pe = TAILQ_FIRST(pathlist)) != NULL) {
+ RB_FOREACH_SAFE(pe, got_pathlist_head, pathlist, temp) {
if (freemask & GOT_PATHLIST_FREE_PATH) {
free((char *)pe->path);
pe->path = NULL;
free(pe->data);
pe->data = NULL;
}
- TAILQ_REMOVE(pathlist, pe, entry);
+ RB_REMOVE(got_pathlist_head, pathlist, pe);
free(pe);
}
}
return NULL;
}
+
+RB_GENERATE(got_pathlist_head, got_pathlist_entry, entry, got_pathlist_cmp);
blob - 4d97f68370673cd0b8596deaab214d88a71a195b
blob + 2c49d4419a4c395afafe7cca1614b53619d50ed5
--- lib/privsep.c
+++ lib/privsep.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/wait.h>
fetchreq.worktree_branch_len = worktree_branch_len;
if (remote_head != NULL)
fetchreq.remote_head_len = remote_head_len;
- TAILQ_FOREACH(pe, have_refs, entry)
+ RB_FOREACH(pe, got_pathlist_head, have_refs)
fetchreq.n_have_refs++;
- TAILQ_FOREACH(pe, wanted_branches, entry)
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches)
fetchreq.n_wanted_branches++;
- TAILQ_FOREACH(pe, wanted_refs, entry)
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs)
fetchreq.n_wanted_refs++;
if (imsg_add(wbuf, &fetchreq, sizeof(fetchreq)) == -1)
return got_error_from_errno("imsg_add FETCH_REQUEST");
if (err)
return err;
- TAILQ_FOREACH(pe, have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, have_refs) {
const char *name = pe->path;
size_t name_len = pe->path_len;
struct got_object_id *id = pe->data;
return err;
}
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
const char *name = pe->path;
size_t name_len = pe->path_len;
return err;
}
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
const char *name = pe->path;
size_t name_len = pe->path_len;
memset(&zero_id, 0, sizeof(zero_id));
memset(&sendreq, 0, sizeof(sendreq));
sendreq.verbosity = verbosity;
- TAILQ_FOREACH(pe, have_refs, entry)
+ RB_FOREACH(pe, got_pathlist_head, have_refs)
sendreq.nrefs++;
- TAILQ_FOREACH(pe, delete_refs, entry)
+ RB_FOREACH(pe, got_pathlist_head, delete_refs)
sendreq.nrefs++;
if (imsg_compose(ibuf, GOT_IMSG_SEND_REQUEST, 0, 0, fd,
&sendreq, sizeof(sendreq)) == -1) {
if (err)
goto done;
- TAILQ_FOREACH(pe, have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head ,have_refs) {
const char *name = pe->path;
size_t name_len = pe->path_len;
struct got_object_id *id = pe->data;
goto done;
}
- TAILQ_FOREACH(pe, delete_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, delete_refs) {
const char *name = pe->path;
size_t name_len = pe->path_len;
err = send_send_ref(name, name_len, &zero_id, 1, ibuf);
blob - b79065ff8ad9f1c2ab6d0c59c7cbb5c02c6b2467
blob + 6737bf650daa76886cbc9ad90d24404103479dd7
--- lib/reference.c
+++ lib/reference.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <errno.h>
blob - f50a14103f7f51da97f88f3efea4286d891e3e65
blob + 693866bdc86723dfd79e3579b540f1364d921c2e
--- lib/repository.c
+++ lib/repository.c
return got_error_from_errno("calloc");
RB_INIT(&repo->packidx_bloom_filters);
- TAILQ_INIT(&repo->packidx_paths);
+ RB_INIT(&repo->packidx_paths);
for (i = 0; i < nitems(repo->privsep_children); i++) {
memset(&repo->privsep_children[i], 0,
{
struct got_pathlist_entry *pe;
- while (!TAILQ_EMPTY(packidx_paths)) {
- pe = TAILQ_FIRST(packidx_paths);
- TAILQ_REMOVE(packidx_paths, pe, entry);
+ while (!RB_EMPTY(packidx_paths)) {
+ pe = RB_MIN(got_pathlist_head, packidx_paths);
+ RB_REMOVE(got_pathlist_head, packidx_paths, pe);
free((char *)pe->path);
free(pe);
}
err = got_error_from_errno2("stat", objects_pack_dir);
goto done;
}
- } else if (TAILQ_EMPTY(&repo->packidx_paths) ||
+ } else if (RB_EMPTY(&repo->packidx_paths) ||
sb.st_mtim.tv_sec != repo->pack_path_mtime.tv_sec ||
sb.st_mtim.tv_nsec != repo->pack_path_mtime.tv_nsec) {
purge_packidx_paths(&repo->packidx_paths);
if (err)
return err;
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
const char *path_packidx = pe->path;
int is_cached = 0;
tv.tv_sec = repo->pack_path_mtime.tv_sec;
tv.tv_nsec = repo->pack_path_mtime.tv_nsec;
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
const char *path_packidx;
struct got_packidx *packidx;
struct got_object_qid *qid;
*new_tree_id = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
dir = opendir(path_dir);
if (dir == NULL) {
if (err)
goto done;
- TAILQ_FOREACH(pe, ignores, entry) {
+ RB_FOREACH(pe, got_pathlist_head, ignores) {
if (type == DT_DIR && pe->path_len > 0 &&
pe->path[pe->path_len - 1] == '/') {
char stripped[PATH_MAX];
nentries++;
}
- if (TAILQ_EMPTY(&paths)) {
+ if (RB_EMPTY(&paths)) {
err = got_error_msg(GOT_ERR_NO_TREE_ENTRY,
"cannot create tree without any entries");
goto done;
}
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
struct got_tree_entry *te = pe->data;
char *path;
if (!S_ISREG(te->mode) && !S_ISLNK(te->mode))
blob - c09e9252dd552a6939292b6dd5653ee79ef2090b
blob + 6c74bdbaad86d5fa1835fd9ad75731dd69cd638b
--- lib/repository_admin.c
+++ lib/repository_admin.c
int remove, redundant_packs = 0;
npacks = 0;
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry)
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths)
npacks++;
if (npacks == 0)
return got_error_from_errno("calloc");
i = 0;
- TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &repo->packidx_paths) {
err = got_repo_get_packidx(&packidx, pe->path, repo);
if (err)
goto done;
blob - 348d1dbb26e60918ccd5c3ea7b3106ec92916e40
blob + 22ef7b9115f249c75e351c48ef60688e463dfa39
--- lib/send.c
+++ lib/send.c
static struct got_pathlist_entry *
find_ref(struct got_pathlist_head *refs, const char *refname)
{
- struct got_pathlist_entry *pe;
+ struct got_pathlist_entry find;
- TAILQ_FOREACH(pe, refs, entry) {
- if (got_path_cmp(pe->path, refname, strlen(pe->path),
- strlen(refname)) == 0) {
- return pe;
- }
- }
+ find.path = refname;
+ find.path_len = strlen(refname);
+ return RB_FIND(got_pathlist_head, refs, &find);
- return NULL;
}
static const struct got_error *
FILE *delta_cache = NULL;
char *s = NULL;
- TAILQ_INIT(&have_refs);
- TAILQ_INIT(&their_refs);
+ RB_INIT(&have_refs);
+ RB_INIT(&their_refs);
if (got_repo_get_object_format(repo) != GOT_HASH_SHA1)
return got_error_fmt(GOT_ERR_NOT_IMPL,
"sha256 object IDs unsupported in network protocol");
- TAILQ_FOREACH(pe, branch_names, entry) {
+ RB_FOREACH(pe, got_pathlist_head, branch_names) {
const char *branchname = pe->path;
const char *targetname = pe->data;
s = NULL;
}
- TAILQ_FOREACH(pe, delete_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, delete_branches) {
const char *branchname = pe->path;
struct got_pathlist_entry *ref;
if (strncmp(branchname, "refs/heads/", 11) != 0) {
}
}
- TAILQ_FOREACH(pe, tag_names, entry) {
+ RB_FOREACH(pe, got_pathlist_head, tag_names) {
const char *tagname = pe->path;
if (strncmp(tagname, "refs/tags/", 10) != 0) {
if (asprintf(&s, "refs/tags/%s", tagname) == -1) {
s = NULL;
}
- if (TAILQ_EMPTY(&have_refs) && TAILQ_EMPTY(delete_branches)) {
+ if (RB_EMPTY(&have_refs) && RB_EMPTY(delete_branches)) {
err = got_error(GOT_ERR_SEND_EMPTY);
goto done;
}
* Prepare the array of our object IDs which
* will be needed for generating a pack file.
*/
- TAILQ_FOREACH(pe, &have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &have_refs) {
struct got_object_id *id = pe->data;
err = realloc_ids(&our_ids, &nalloc_ours, nours + 1);
* This array will be used to exclude objects which already
* exist on the server from our pack file.
*/
- TAILQ_FOREACH(pe, &their_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &their_refs) {
const char *refname = pe->path;
struct got_object_id *their_id = pe->data;
int have_their_id;
}
/* Account for any new references we are going to upload. */
- TAILQ_FOREACH(pe, &have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &have_refs) {
const char *refname = pe->path;
if (find_ref(&their_refs, refname) == NULL)
refs_to_send++;
}
/* Account for any existing references we are going to delete. */
- TAILQ_FOREACH(pe, delete_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, delete_branches) {
const char *branchname = pe->path;
if (find_ref(&their_refs, branchname))
refs_to_delete++;
blob - c8fe03020a4cf36fb6886cdd20c9f5c8c14ba2fd
blob + 4a2bab0b7932ec20883e152b231992ed8b75e0f4
--- lib/serve.c
+++ lib/serve.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <errno.h>
blob - 936dc8f7691a930afed9b877b099366102eecf50
blob + df89f493b283c3c8957846b5f60994c98756d8ae
--- lib/worktree.c
+++ lib/worktree.c
goto done;
/* Map all specified paths to in-repository trees. */
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
tpd = malloc(sizeof(*tpd));
if (tpd == NULL) {
err = got_error_from_errno("malloc");
goto done;
tpd = STAILQ_FIRST(&tree_paths);
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
struct bump_base_commit_id_arg bbc_arg;
err = checkout_files(worktree, fileindex, tpd->relpath,
{
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, ignores, entry) {
+ RB_FOREACH(pe, got_pathlist_head, ignores) {
struct got_pathlist_head *ignorelist = pe->data;
got_pathlist_free(ignorelist, GOT_PATHLIST_FREE_PATH);
ignorelist = calloc(1, sizeof(*ignorelist));
if (ignorelist == NULL)
return got_error_from_errno("calloc");
- TAILQ_INIT(ignorelist);
+ RB_INIT(ignorelist);
while ((linelen = getline(&line, &linesize, f)) != -1) {
if (linelen > 0 && line[linelen - 1] == '\n')
struct got_pathlist_entry *pe;
/* Handle patterns which match in all directories. */
- TAILQ_FOREACH(pe, ignores, entry) {
+ RB_FOREACH(pe, got_pathlist_head, ignores) {
struct got_pathlist_head *ignorelist = pe->data;
struct got_pathlist_entry *pi;
- TAILQ_FOREACH(pi, ignorelist, entry) {
+ RB_FOREACH(pi, got_pathlist_head, ignorelist) {
const char *p;
if (pi->path_len < 3 ||
* parents, so we can find the most specific ignorelist by walking
* ignores backwards.
*/
- pe = TAILQ_LAST(ignores, got_pathlist_head);
+ pe = RB_MAX(got_pathlist_head, ignores);
while (pe) {
if (got_path_is_child(path, pe->path, pe->path_len)) {
struct got_pathlist_head *ignorelist = pe->data;
struct got_pathlist_entry *pi;
- TAILQ_FOREACH(pi, ignorelist, entry) {
+ RB_FOREACH(pi, got_pathlist_head, ignorelist) {
int flags = FNM_LEADING_DIR;
if (strstr(pi->path, "/**/") == NULL)
flags |= FNM_PATHNAME;
return 1;
}
}
- pe = TAILQ_PREV(pe, got_pathlist_head, entry);
+ pe = RB_PREV(got_pathlist_head, ignores, pe);
}
return 0;
struct got_pathlist_entry *pe;
char *ondisk_path = NULL;
- TAILQ_FOREACH(pe, children, entry) {
+ RB_FOREACH(pe, got_pathlist_head, children) {
if (cancel_cb) {
err = cancel_cb(cancel_arg);
if (err)
struct got_pathlist_head ignores, missing_children;
struct got_fileindex_entry *ie;
- TAILQ_INIT(&ignores);
- TAILQ_INIT(&missing_children);
+ RB_INIT(&ignores);
+ RB_INIT(&missing_children);
if (asprintf(&ondisk_path, "%s%s%s",
worktree->root_path, path[0] ? "/" : "", path) == -1)
if (err)
goto done;
}
- if (TAILQ_EMPTY(&missing_children)) {
+ if (RB_EMPTY(&missing_children)) {
err = report_single_file_status(path,
ondisk_path, fileindex,
status_cb, status_arg, repo,
if (err)
return err;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
status_cb, status_arg, cancel_cb, cancel_arg,
no_ignores, 0);
saa.progress_arg = progress_arg;
saa.repo = repo;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
schedule_addition, &saa, NULL, NULL, no_ignores, 0);
if (err)
sda.ignore_missing_paths = ignore_missing_paths;
sda.status_codes = status_codes;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
char *ondisk_status_path;
if (asprintf(&ondisk_status_path, "%s%s%s",
if (a->added_files_to_unlink) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, a->added_files_to_unlink,
- entry) {
+ RB_FOREACH(pe, got_pathlist_head,
+ a->added_files_to_unlink) {
if (got_path_cmp(pe->path, relpath,
pe->path_len, strlen(relpath)))
continue;
rfa.patch_arg = patch_arg;
rfa.repo = repo;
rfa.unlink_added_files = 0;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
revert_file, &rfa, NULL, NULL, 1, 0);
if (err)
te->name) == -1)
return got_error_from_errno("asprintf");
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
*modified = got_path_is_child(ct->in_repo_path, te_path,
strlen(te_path));
*ctp = NULL;
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *ct_name = NULL;
int path_matches;
struct got_tree_entry *te, *new_te = NULL;
struct got_pathlist_entry *pe;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
*nentries = 0;
/* Insert, and recurse into, newly added entries first. */
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *child_path = NULL, *slash;
struct got_pathlist_entry *pe;
char *relpath = NULL;
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_fileindex_entry *ie;
struct got_commitable *ct = pe->data;
}
/* Create blobs from added and modified files and record their IDs. */
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *ondisk_path;
struct got_pathlist_entry *cpe = NULL;
size_t path_len = strlen(path);
- TAILQ_FOREACH(cpe, commitable_paths, entry) {
+ RB_FOREACH(cpe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = cpe->data;
const char *ct_path = ct->path;
struct got_pathlist_entry *pe;
struct got_fileindex_entry *ie;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
if (pe->path[0] == '\0')
continue;
ie = got_fileindex_entry_get(fileindex, pe->path, pe->path_len);
*new_commit_id = NULL;
memset(&cc_arg, 0, sizeof(cc_arg));
- TAILQ_INIT(&commitable_paths);
+ RB_INIT(&commitable_paths);
err = lock_worktree(worktree, LOCK_EX);
if (err)
}
}
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
collect_commitables, &cc_arg, NULL, NULL, 0, 0);
if (err)
}
}
- if (TAILQ_EMPTY(&commitable_paths)) {
+ if (RB_EMPTY(&commitable_paths)) {
err = got_error(GOT_ERR_COMMIT_NO_CHANGES);
goto done;
}
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = check_path_is_commitable(pe->path, &commitable_paths);
if (err)
goto done;
}
- TAILQ_FOREACH(pe, &commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &commitable_paths) {
struct got_commitable *ct = pe->data;
const char *ct_path = ct->in_repo_path;
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
err = unlockerr;
- TAILQ_FOREACH(pe, &commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &commitable_paths) {
struct got_commitable *ct = pe->data;
free_commitable(ct);
char *logmsg = NULL;
memset(&cc_arg, 0, sizeof(cc_arg));
- TAILQ_INIT(&commitable_paths);
+ RB_INIT(&commitable_paths);
*new_commit_id = NULL;
/* Work tree is locked/unlocked during rebase preparation/teardown. */
*/
if (merged_paths) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, merged_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, merged_paths) {
err = worktree_status(worktree, pe->path, fileindex,
repo, collect_commitables, &cc_arg, NULL, NULL, 1,
0);
goto done;
}
- if (TAILQ_EMPTY(&commitable_paths)) {
+ if (RB_EMPTY(&commitable_paths)) {
/* No-op change; commit will be elided. */
err = got_ref_delete(commit_ref, repo);
if (err)
struct got_pathlist_entry *pe;
char *abspath = NULL, *wt_path = NULL;
- TAILQ_INIT(&merged_paths);
+ RB_INIT(&merged_paths);
err = get_paths_changed_between_commits(&merged_paths, id1, id2, repo);
if (err)
goto done;
- TAILQ_FOREACH(pe, &merged_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &merged_paths) {
struct got_diff_changed_path *change = pe->data;
if (change->status != GOT_STATUS_ADD)
struct got_object_id *tree_id = NULL;
struct got_pathlist_head added_paths;
- TAILQ_INIT(&added_paths);
+ RB_INIT(&added_paths);
err = lock_worktree(worktree, LOCK_EX);
if (err)
struct revert_file_args rfa;
struct got_pathlist_head added_paths;
- TAILQ_INIT(&added_paths);
+ RB_INIT(&added_paths);
err = lock_worktree(worktree, LOCK_EX);
if (err)
memset(&cc_arg, 0, sizeof(cc_arg));
*new_commit_id = NULL;
- TAILQ_INIT(&commitable_paths);
+ RB_INIT(&commitable_paths);
err = get_fileindex_path(&fileindex_path, worktree);
if (err)
if (sync_err && err == NULL)
err = sync_err;
done:
- TAILQ_FOREACH(pe, &commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &commitable_paths) {
struct got_commitable *ct = pe->data;
free_commitable(ct);
struct got_object_id *tree_id = NULL;
struct got_pathlist_head added_paths;
- TAILQ_INIT(&added_paths);
+ RB_INIT(&added_paths);
err = get_merge_commit_ref_name(&commit_ref_name, worktree);
if (err)
oka.fileindex = fileindex;
oka.repo = repo;
oka.have_changes = 0;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
check_stage_ok, &oka, NULL, NULL, 1, 0);
if (err)
spa.status_arg = status_arg;
spa.staged_something = 0;
spa.allow_bad_symlinks = allow_bad_symlinks;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
stage_path, &spa, NULL, NULL, 1, 0);
if (err)
upa.progress_arg = progress_arg;
upa.patch_cb = patch_cb;
upa.patch_arg = patch_arg;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
unstage_path, &upa, NULL, NULL, 1, 0);
if (err)
return err;
}
- TAILQ_FOREACH(pe, a->paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, a->paths) {
if (pe->path_len == 0 || strcmp(pe->path, ie->path) == 0 ||
got_path_is_child(ie->path, pe->path, pe->path_len))
break;
blob - b9abd5bf360259fba46644942a97cd1cc76f4b9f
blob + 4518253bb1454bef6d43a7a09d1bdc0b73168086
--- lib/worktree_cvg.c
+++ lib/worktree_cvg.c
{
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, ignores, entry) {
+ RB_FOREACH(pe, got_pathlist_head, ignores) {
struct got_pathlist_head *ignorelist = pe->data;
got_pathlist_free(ignorelist, GOT_PATHLIST_FREE_PATH);
ignorelist = calloc(1, sizeof(*ignorelist));
if (ignorelist == NULL)
return got_error_from_errno("calloc");
- TAILQ_INIT(ignorelist);
+ RB_INIT(ignorelist);
while ((linelen = getline(&line, &linesize, f)) != -1) {
if (linelen > 0 && line[linelen - 1] == '\n')
struct got_pathlist_entry *pe;
/* Handle patterns which match in all directories. */
- TAILQ_FOREACH(pe, ignores, entry) {
+ RB_FOREACH(pe, got_pathlist_head, ignores) {
struct got_pathlist_head *ignorelist = pe->data;
struct got_pathlist_entry *pi;
- TAILQ_FOREACH(pi, ignorelist, entry) {
+ RB_FOREACH(pi, got_pathlist_head, ignorelist) {
const char *p;
if (pi->path_len < 3 ||
* parents, so we can find the most specific ignorelist by walking
* ignores backwards.
*/
- pe = TAILQ_LAST(ignores, got_pathlist_head);
+ pe = RB_MAX(got_pathlist_head, ignores);
while (pe) {
if (got_path_is_child(path, pe->path, pe->path_len)) {
struct got_pathlist_head *ignorelist = pe->data;
struct got_pathlist_entry *pi;
- TAILQ_FOREACH(pi, ignorelist, entry) {
+ RB_FOREACH(pi, got_pathlist_head, ignorelist) {
int flags = FNM_LEADING_DIR;
if (strstr(pi->path, "/**/") == NULL)
flags |= FNM_PATHNAME;
return 1;
}
}
- pe = TAILQ_PREV(pe, got_pathlist_head, entry);
+ pe = RB_PREV(got_pathlist_head, ignores, pe);
}
return 0;
struct got_pathlist_entry *pe;
char *ondisk_path = NULL;
- TAILQ_FOREACH(pe, children, entry) {
+ RB_FOREACH(pe, got_pathlist_head, children) {
if (cancel_cb) {
err = cancel_cb(cancel_arg);
if (err)
struct got_pathlist_head ignores, missing_children;
struct got_fileindex_entry *ie;
- TAILQ_INIT(&ignores);
- TAILQ_INIT(&missing_children);
+ RB_INIT(&ignores);
+ RB_INIT(&missing_children);
if (asprintf(&ondisk_path, "%s%s%s",
worktree->root_path, path[0] ? "/" : "", path) == -1)
if (err)
goto done;
}
- if (TAILQ_EMPTY(&missing_children)) {
+ if (RB_EMPTY(&missing_children)) {
err = report_single_file_status(path,
ondisk_path, fileindex,
status_cb, status_arg, repo,
te->name) == -1)
return got_error_from_errno("asprintf");
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
*modified = got_path_is_child(ct->in_repo_path, te_path,
strlen(te_path));
*ctp = NULL;
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *ct_name = NULL;
int path_matches;
struct got_tree_entry *te, *new_te = NULL;
struct got_pathlist_entry *pe;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
*nentries = 0;
/* Insert, and recurse into, newly added entries first. */
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *child_path = NULL, *slash;
struct got_pathlist_entry *pe;
char *relpath = NULL;
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_fileindex_entry *ie;
struct got_commitable *ct = pe->data;
}
/* Create blobs from added and modified files and record their IDs. */
- TAILQ_FOREACH(pe, commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = pe->data;
char *ondisk_path;
struct got_pathlist_entry *cpe = NULL;
size_t path_len = strlen(path);
- TAILQ_FOREACH(cpe, commitable_paths, entry) {
+ RB_FOREACH(cpe, got_pathlist_head, commitable_paths) {
struct got_commitable *ct = cpe->data;
const char *ct_path = ct->path;
struct got_pathlist_entry *pe;
struct got_fileindex_entry *ie;
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
if (pe->path[0] == '\0')
continue;
ie = got_fileindex_entry_get(fileindex, pe->path, pe->path_len);
if (success) {
struct got_pathlist_entry *pe;
- TAILQ_FOREACH(pe, a->delete_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, a->delete_branches) {
const char *branchname = pe->path;
if (got_path_cmp(branchname, refname,
strlen(branchname), strlen(refname)) == 0) {
int fetchfd = -1;
pid_t fetchpid = -1;
- TAILQ_INIT(&learned_refs);
- TAILQ_INIT(&symrefs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&learned_refs);
+ RB_INIT(&symrefs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
err = got_pathlist_insert(NULL, &wanted_branches, head_refname,
NULL);
goto done;
/* Update references provided with the pack file. */
- TAILQ_FOREACH(pe, &learned_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &learned_refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
struct got_reference *ref;
}
/* Set the HEAD reference if the server provided one. */
- TAILQ_FOREACH(pe, &symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &symrefs) {
struct got_reference *target_ref;
const char *refname = pe->path;
const char *target = pe->data;
*new_commit_id = NULL;
memset(&cc_arg, 0, sizeof(cc_arg));
- TAILQ_INIT(&commitable_paths);
- TAILQ_INIT(&commit_reflist);
- TAILQ_INIT(&tag_names);
- TAILQ_INIT(&delete_branches);
+ RB_INIT(&commitable_paths);
+ RB_INIT(&commit_reflist);
+ RB_INIT(&tag_names);
+ RB_INIT(&delete_branches);
err = lock_worktree(worktree, LOCK_EX);
if (err)
}
}
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = worktree_status(worktree, pe->path, fileindex, repo,
collect_commitables, &cc_arg, NULL, NULL, 0, 0);
if (err)
}
}
- if (TAILQ_EMPTY(&commitable_paths)) {
+ if (RB_EMPTY(&commitable_paths)) {
err = got_error(GOT_ERR_COMMIT_NO_CHANGES);
goto done;
}
- TAILQ_FOREACH(pe, paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, paths) {
err = check_path_is_commitable(pe->path, &commitable_paths);
if (err)
goto done;
}
- TAILQ_FOREACH(pe, &commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &commitable_paths) {
struct got_commitable *ct = pe->data;
const char *ct_path = ct->in_repo_path;
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
err = unlockerr;
- TAILQ_FOREACH(pe, &commitable_paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &commitable_paths) {
struct got_commitable *ct = pe->data;
free_commitable(ct);
blob - 1855ba0c1a557ce16cfae9790d6cff44a4b71846
blob + 6ae0f96f5546d6f7eaac0b1b2d32dd6249c51d52
--- lib/worktree_open.c
+++ lib/worktree_open.c
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <errno.h>
#include <fcntl.h>
blob - 235f88168eaa1209540cb280c17e4f55629259a4
blob + 6f0e0e861b6c26170d813b19ca2271295f30eb22
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/socket.h>
#include <err.h>
blob - 167dff0291b3356987b3f2dbe74509ad4a608813
blob + 941d899ffe34503cf9f82ba20f3e587581c384df
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/stat.h>
* we should use a flag instead */
memset(my_id, 0, sizeof(*my_id));
- TAILQ_FOREACH(pe, have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, have_refs) {
struct got_object_id *id = pe->data;
if (strcmp(pe->path, refname) == 0) {
memcpy(my_id, id, sizeof(*my_id));
struct got_pathlist_entry *pe;
len = sizeof(struct got_imsg_fetch_symrefs);
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *target = pe->data;
len += sizeof(struct got_imsg_fetch_symref) +
pe->path_len + strlen(target);
if (imsg_add(wbuf, &nsymrefs, sizeof(nsymrefs)) == -1)
return got_error_from_errno("imsg_add FETCH_SYMREFS");
- TAILQ_FOREACH(pe, symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, symrefs) {
const char *name = pe->path;
size_t name_len = pe->path_len;
const char *target = pe->data;
ssize_t w;
struct got_ratelimit rl;
- TAILQ_INIT(&symrefs);
+ RB_INIT(&symrefs);
got_hash_init(&ctx, GOT_HASH_SHA1);
got_ratelimit_init(&rl, 0, 500);
goto done;
is_firstpkt = 0;
if (!fetch_all_branches) {
- TAILQ_FOREACH(pe, &symrefs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &symrefs) {
const char *name = pe->path;
const char *symref_target = pe->data;
if (strcmp(name, GOT_REF_HEAD) != 0)
found_branch = 1;
continue;
}
- TAILQ_FOREACH(pe, wanted_branches, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_branches) {
if (match_branch(refname, pe->path))
break;
}
getprogname(), refname);
}
} else {
- TAILQ_FOREACH(pe, wanted_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, wanted_refs) {
if (match_wanted_ref(refname, pe->path))
break;
}
struct got_pathlist_entry *pe;
static char msg[PATH_MAX + 33];
- pe = TAILQ_FIRST(wanted_branches);
+ pe = RB_MIN(got_pathlist_head, wanted_branches);
if (pe) {
snprintf(msg, sizeof(msg),
"branch \"%s\" not found on server", pe->path);
goto done;
}
- pe = TAILQ_FIRST(wanted_refs);
+ pe = RB_MIN(got_pathlist_head, wanted_refs);
if (pe) {
snprintf(msg, sizeof(msg),
"reference \"%s\" not found on server", pe->path);
if (nwant == 0)
goto done;
- TAILQ_FOREACH(pe, have_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, have_refs) {
struct got_object_id *id = pe->data;
got_object_id_hex(id, hashstr, sizeof(hashstr));
n = snprintf(buf, sizeof(buf), "have %s\n", hashstr);
sleep (1);
#endif
- TAILQ_INIT(&have_refs);
- TAILQ_INIT(&wanted_branches);
- TAILQ_INIT(&wanted_refs);
+ RB_INIT(&have_refs);
+ RB_INIT(&wanted_branches);
+ RB_INIT(&wanted_refs);
if (imsgbuf_init(&ibuf, GOT_IMSG_FD_CHILD) == -1) {
warn("imsgbuf_init");
blob - e7b041c41a36e5ab990a86d621f4e250a2599450
blob + 30b538316b641b0ebb47883992192f2d69452e31
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/mman.h>
#include <sys/uio.h>
blob - 26152f5caf9edaa7ef001a84a9f9af447d60647c
blob + 0621ad9a6a25c713308398a2e153f6b04d0796f8
--- libexec/got-read-gotconfig/got-read-gotconfig.c
+++ libexec/got-read-gotconfig/got-read-gotconfig.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/time.h>
blob - b757db4cd2a5046393449b4f1e7a5611c6fce25a
blob + 02824e8cfc0fa0fcfb71a91e9fdb9ecabf8545ec
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/mman.h>
blob - ebf6949188e7f189d1ca4bf3eb6652f668d4f96c
blob + 417db9c87500ce3e9b5dcc9a6784d94fa465f657
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/time.h>
blob - a7c50b87c17ac2535d33e80601a9f5b054441d8f
blob + 1f5f72593dca228e5752bbe2703e47723bda37c2
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/stat.h>
"unexpected message from server");
}
- TAILQ_FOREACH(pe, refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, refs) {
if (strcmp(refname, pe->path) == 0) {
ref_valid = 1;
break;
}
}
if (!ref_valid) {
- TAILQ_FOREACH(pe, delete_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, delete_refs) {
if (strcmp(refname, pe->path) == 0) {
ref_valid = 1;
break;
struct got_pathlist_entry *pe;
int sent_my_capabilites = 0;
- TAILQ_INIT(&their_refs);
+ RB_INIT(&their_refs);
- if (TAILQ_EMPTY(refs) && TAILQ_EMPTY(delete_refs))
+ if (RB_EMPTY(refs) && RB_EMPTY(delete_refs))
return got_error(GOT_ERR_SEND_EMPTY);
while (1) {
id = NULL; /* do not free; owned by their_refs */
}
- if (!TAILQ_EMPTY(delete_refs)) {
+ if (!RB_EMPTY(delete_refs)) {
if (my_capabilities == NULL ||
strstr(my_capabilities, GOT_CAPA_DELETE_REFS) == NULL) {
err = got_error(GOT_ERR_CAPA_DELETE_REFS);
}
}
- TAILQ_FOREACH(pe, delete_refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, delete_refs) {
const char *refname = pe->path;
struct got_pathlist_entry *their_pe;
struct got_object_id *their_id = NULL;
- TAILQ_FOREACH(their_pe, &their_refs, entry) {
+ RB_FOREACH(their_pe, got_pathlist_head, &their_refs) {
const char *their_refname = their_pe->path;
if (got_path_cmp(refname, their_refname,
strlen(refname), strlen(their_refname)) == 0) {
nsent++;
}
- TAILQ_FOREACH(pe, refs, entry) {
+ RB_FOREACH(pe, got_pathlist_head, refs) {
const char *refname = pe->path;
struct got_object_id *id = pe->data;
struct got_object_id *their_id = NULL;
struct got_pathlist_entry *their_pe;
- TAILQ_FOREACH(their_pe, &their_refs, entry) {
+ RB_FOREACH(their_pe, got_pathlist_head, &their_refs) {
const char *their_refname = their_pe->path;
if (got_path_cmp(refname, their_refname,
strlen(refname), strlen(their_refname)) == 0) {
sleep (1);
#endif
- TAILQ_INIT(&refs);
- TAILQ_INIT(&delete_refs);
+ RB_INIT(&refs);
+ RB_INIT(&delete_refs);
if (imsgbuf_init(&ibuf, GOT_IMSG_FD_CHILD) == -1) {
warn("imsgbuf_init");
blob - 377ea9cd19e22c07f1348e7110a49defd8cb974d
blob + b0b1593dc092b51883cce8fc1caf672b00d56560
--- regress/delta/delta_test.c
+++ regress/delta/delta_test.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <stdio.h>
#include <stdlib.h>
blob - c024c69ae8a0fd18330ae5c8f6dc6b872026966e
blob + e3b7eda734c43ae229647e428258d944538ab041
--- regress/fetch/fetch_test.c
+++ regress/fetch/fetch_test.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <limits.h>
#include <stdarg.h>
blob - fad15574f54715f8f62105579fbc58c1ca5d1bf1
blob + c4da368ef9fe5fb3b4c6ff3a0879637e0a4a2611
--- regress/path/path_test.c
+++ regress/path/path_test.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <string.h>
#include <stdlib.h>
struct got_pathlist_entry *pe;
size_t i;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
for (i = 0; i < nitems(path_list_input); i++) {
err = got_pathlist_insert(NULL, &paths, path_list_input[i],
NULL);
}
i = 0;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
test_printf("'%s' -- '%s'\n", pe->path, path_list_expected[i]);
if (i >= nitems(path_list_expected)) {
test_printf("too many elements on list\n");
struct got_pathlist_entry *pe;
size_t i;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
for (i = nitems(path_list_input); i > 0;) {
err = got_pathlist_insert(NULL, &paths, path_list_input[--i],
NULL);
}
i = 0;
- TAILQ_FOREACH(pe, &paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, &paths) {
test_printf("'%s' -- '%s'\n", pe->path,
path_list_expected_reverse[i]);
if (i >= nitems(path_list_expected_reverse)) {
blob - 7dd3a24c5a2515f0073943bd56830d25bf86f45a
blob + 8ba0b402891597607aa828b626aea058f21769eb
--- tog/tog.c
+++ tog/tog.c
*/
#include <sys/queue.h>
+#include <sys/tree.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
char *cwd = NULL;
int wt_state = 0;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
if (wt == NULL) {
cwd = getcwd(NULL, 0);
} else
offset = (*lines)[*nlines - 1].offset;
- TAILQ_FOREACH(pe, dsa->paths, entry) {
+ RB_FOREACH(pe, got_pathlist_head, dsa->paths) {
struct got_diff_changed_path *cp = pe->data;
int pad = dsa->max_path_len - pe->path_len + 1;
struct got_pathlist_head pathlist;
char *cwd, *id_str = NULL;
- TAILQ_INIT(&pathlist);
+ RB_INIT(&pathlist);
cwd = getcwd(NULL, 0);
if (cwd == NULL)
struct got_diffstat_cb_arg dsa;
size_t nlines = 0;
- TAILQ_INIT(&changed_paths);
+ RB_INIT(&changed_paths);
memset(&dsa, 0, sizeof(dsa));
dsa.paths = &changed_paths;
dsa.diff_algo = tog_diff_algo;
struct tog_view *view;
int *pack_fds = NULL;
- TAILQ_INIT(&paths);
+ RB_INIT(&paths);
while ((ch = getopt(argc, argv, "aC:c:r:sw")) != -1) {
switch (ch) {