commit - 799728f7aeb4842a6458eccfc51df84e5cbc40d0
commit + 6f86da294d3b81aba4c403d76e423598958c2100
blob - 7864138db9fadd684f9cc01f99ab36941f60e2fd
blob + f32badb418f5f48bf31962de1a6ac52d4c04c400
--- cvg/cvg.c
+++ cvg/cvg.c
fetch_all_branches = 1;
break;
case 'b':
- error = got_pathlist_append(&wanted_branches,
+ error = got_pathlist_insert(NULL, &wanted_branches,
optarg, NULL);
if (error)
return error;
verbosity = -1;
break;
case 'R':
- error = got_pathlist_append(&wanted_refs,
+ error = got_pathlist_insert(NULL, &wanted_refs,
optarg, NULL);
if (error)
return error;
goto done;
}
- error = got_pathlist_append(&paths, "", NULL);
+ error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
cpa.worktree_path = worktree_path;
path = strdup("");
if (path == NULL)
return got_error_from_errno("strdup");
- return got_pathlist_append(paths, path, NULL);
+ return got_pathlist_insert(NULL, paths, path, NULL);
}
for (i = 0; i < argc; i++) {
blob - 8a69602e91a117f6b3b1826abfe7737979fbf616
blob + f890b946e6565aa7acf7271c37921844fa902230
--- got/got.c
+++ got/got.c
fetch_all_branches = 1;
break;
case 'b':
- error = got_pathlist_append(&wanted_branches,
+ error = got_pathlist_insert(NULL, &wanted_branches,
optarg, NULL);
if (error)
return error;
verbosity = -1;
break;
case 'R':
- error = got_pathlist_append(&wanted_refs,
+ error = got_pathlist_insert(NULL, &wanted_refs,
optarg, NULL);
if (error)
return error;
fetch_all_branches = 1;
break;
case 'b':
- error = got_pathlist_append(&wanted_branches,
+ error = got_pathlist_insert(NULL, &wanted_branches,
optarg, NULL);
if (error)
return error;
verbosity = -1;
break;
case 'R':
- error = got_pathlist_append(&wanted_refs,
+ error = got_pathlist_insert(NULL, &wanted_refs,
optarg, NULL);
if (error)
return error;
if (!fetch_all_branches)
fetch_all_branches = remote->fetch_all_branches;
for (i = 0; i < remote->nfetch_branches; i++) {
- error = got_pathlist_append(&wanted_branches,
+ error = got_pathlist_insert(NULL, &wanted_branches,
remote->fetch_branches[i], NULL);
if (error)
goto done;
}
if (TAILQ_EMPTY(&wanted_refs)) {
for (i = 0; i < remote->nfetch_refs; i++) {
- error = got_pathlist_append(&wanted_refs,
+ error = got_pathlist_insert(NULL, &wanted_refs,
remote->fetch_refs[i], NULL);
if (error)
goto done;
goto done;
}
- error = got_pathlist_append(&paths, "", NULL);
+ error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
cpa.worktree_path = worktree_path;
path = strdup("");
if (path == NULL)
return got_error_from_errno("strdup");
- return got_pathlist_append(paths, path, NULL);
+ return got_pathlist_insert(NULL, paths, path, NULL);
}
for (i = 0; i < argc; i++) {
send_all_branches = 1;
break;
case 'b':
- error = got_pathlist_append(&branches, optarg, NULL);
+ error = got_pathlist_insert(NULL, &branches, optarg, NULL);
if (error)
return error;
nbranches++;
break;
case 'd':
- error = got_pathlist_append(&delete_args, optarg, NULL);
+ error = got_pathlist_insert(NULL, &delete_args, optarg, NULL);
if (error)
return error;
break;
send_all_tags = 1;
break;
case 't':
- error = got_pathlist_append(&tags, optarg, NULL);
+ error = got_pathlist_insert(NULL, &tags, optarg, NULL);
if (error)
return error;
break;
goto done;
TAILQ_FOREACH(re, &all_branches, entry) {
const char *branchname = got_ref_get_name(re->ref);
- error = got_pathlist_append(&branches,
+ error = got_pathlist_insert(NULL, &branches,
branchname, NULL);
if (error)
goto done;
}
} else if (nbranches == 0) {
for (i = 0; i < remote->nsend_branches; i++) {
- error = got_pathlist_append(&branches,
+ error = got_pathlist_insert(NULL, &branches,
remote->send_branches[i], NULL);
if (error)
goto done;
goto done;
TAILQ_FOREACH(re, &all_tags, entry) {
const char *tagname = got_ref_get_name(re->ref);
- error = got_pathlist_append(&tags,
+ error = got_pathlist_insert(NULL, &tags,
tagname, NULL);
if (error)
goto done;
goto done;
} else
ref = head_ref;
- error = got_pathlist_append(&branches, got_ref_get_name(ref),
+ error = got_pathlist_insert(NULL, &branches, got_ref_get_name(ref),
NULL);
if (error)
goto done;
if (error)
goto done;
TAILQ_INIT(&paths);
- error = got_pathlist_append(&paths, "", NULL);
+ error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
error = got_worktree_checkout_files(worktree,
int have_changes = 0;
TAILQ_INIT(&paths);
- error = got_pathlist_append(&paths, "", NULL);
+ error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
error = got_worktree_status(worktree, &paths,
if (error)
goto done;
TAILQ_INIT(&paths);
- error = got_pathlist_append(&paths, "", NULL);
+ error = got_pathlist_insert(NULL, &paths, "", NULL);
if (error)
goto done;
error = got_worktree_checkout_files(worktree,
blob - 6678a9dd097384ee9c7b2545f4a1e9211a83054d
blob + b4498d7b27edc861c011a977cef6c8b66603f09d
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
break;
case 'x':
got_path_strip_trailing_slashes(optarg);
- error = got_pathlist_append(&exclude_args,
+ error = got_pathlist_insert(NULL, &exclude_args,
optarg, NULL);
if (error)
return error;
got_path_strip_trailing_slashes(repo_path);
break;
case 'x':
- error = got_pathlist_append(&exclude_args,
+ error = got_pathlist_insert(NULL, &exclude_args,
optarg, NULL);
if (error)
return error;
got_path_strip_trailing_slashes(refname);
if (!got_ref_name_is_valid(refname))
errx(1, "invalid reference name %s", refname);
- error = got_pathlist_append(&include_args, refname, NULL);
+ error = got_pathlist_insert(NULL, &include_args, refname, NULL);
if (error)
goto done;
}
blob - b2bcaa2b7774cab98d41dad2df3c7777d72b0d4b
blob + 1100e919033e225f9500e38d04dc8c9304369742
--- include/got_path.h
+++ include/got_path.h
const struct got_error *got_pathlist_insert(struct got_pathlist_entry **,
struct got_pathlist_head *, const char *, void *);
-/*
- * Append a path to the list of paths.
- * The caller should already have initialized the list head. This list stores
- * the pointer to the path as-is, i.e. the path is not copied internally and
- * must remain available until the list is freed with got_pathlist_free().
- */
-const struct got_error *got_pathlist_append(struct got_pathlist_head *,
- const char *, void *);
-
/* Flags passed to got_pathlist_free() to control which pointers are freed. */
#define GOT_PATHLIST_FREE_NONE 0 /* pathlist entry only */
#define GOT_PATHLIST_FREE_PATH (1 << 0) /* entry and path pointer */
blob - 1958bf239d21b4b220fed7b8cb12e942ed4b8c24
blob + 927f39266460c90e8f4c6574b83b64526a9bc468
--- lib/diff.c
+++ lib/diff.c
ds->del += change->rm;
++ds->nfiles;
- err = got_pathlist_append(ds->paths, path, change);
- if (err) {
+ err = got_pathlist_insert(&pe, ds->paths, path, change);
+ if (err || pe == NULL) {
free(change);
- return err;
+ if (err)
+ return err;
}
pe = TAILQ_LAST(ds->paths, got_pathlist_head);
{
const struct got_error *err = NULL;
struct got_pathlist_head *paths = arg;
+ struct got_pathlist_entry *new;
struct got_diff_changed_path *change = NULL;
char *path = NULL;
change->status = GOT_STATUS_MODE_CHANGE;
}
- err = got_pathlist_append(paths, path, change);
+ err = got_pathlist_insert(&new, paths, path, change);
done:
- if (err) {
+ if (err || new == NULL) {
free(path);
free(change);
}
blob - 4d56359502a5b5c1e7fc70c62f2355e4e13e7960
blob + 1fbe141ad4fdf719e9063bc6be0a064606e32eeb
--- lib/fetch.c
+++ lib/fetch.c
char *packpath = NULL, *idxpath = NULL, *id_str = NULL;
const char *repo_path = NULL;
struct got_pathlist_head have_refs;
- struct got_pathlist_entry *pe;
+ struct got_pathlist_entry *pe, *new;
struct got_reflist_head my_refs;
struct got_reflist_entry *re;
off_t packfile_size = 0;
err = got_error_from_errno("strdup");
goto done;
}
- err = got_pathlist_append(&have_refs, refname, id);
+ err = got_pathlist_insert(&new, &have_refs, refname, id);
if (err)
goto done;
+ if (new == NULL){
+ free(&refname);
+ free(id);
+ }
+
}
if (list_refs_only) {
blob - ca1719dd8649b956e27783774efab623fdba7ed8
blob + 7bf09a8a6503e2cf488f090ab7a98b0a0762ae04
--- lib/gitproto.c
+++ lib/gitproto.c
{
const struct got_error *err = NULL;
char *colon, *name = NULL, *target = NULL;
+ struct got_pathlist_entry *new;
/* Need at least "A:B" */
if (strlen(capa) < 3)
}
/* We can't validate the ref itself here. The main process will. */
- err = got_pathlist_append(symrefs, name, target);
+ err = got_pathlist_insert(&new, symrefs, name, target);
+ if (err == NULL && new == NULL)
+ err = got_error(GOT_ERR_REF_DUP_ENTRY);
done:
if (err) {
free(name);
if (equalsign != NULL && symrefs != NULL &&
strncmp(capa, "symref", equalsign - capa) == 0) {
err = add_symref(symrefs, equalsign + 1);
- if (err)
+ if (err && err->code != GOT_ERR_REF_DUP_ENTRY)
break;
continue;
}
blob - be080572089318fc90fd9461180ce5d13c92521e
blob + d9b43df9dfbb89553d6f95931f5ef24cb8e2d9cf
--- lib/load.c
+++ lib/load.c
for (;;) {
struct got_object_id *id;
char *dup;
+ struct got_pathlist_entry *new;
linelen = getline(&line, &linesize, in);
if (linelen == -1) {
goto done;
}
- err = got_pathlist_append(refs_found, dup, id);
- if (err) {
+ err = got_pathlist_insert(&new, refs_found, dup, id);
+ if (err || new == NULL) {
free(id);
free(dup);
- goto done;
+ if (err)
+ goto done;
}
}
blob - c91ca76066d628e1d12b7c66d86c8829e1b938be
blob + 8242bbe0f1553766e05f3b6750c7a283387e0907
--- lib/path.c
+++ lib/path.c
TAILQ_INSERT_HEAD(pathlist, new, entry);
if (inserted)
*inserted = new;
- return NULL;
-}
-
-const struct got_error *
-got_pathlist_append(struct got_pathlist_head *pathlist,
- const char *path, void *data)
-{
- struct got_pathlist_entry *new;
-
- new = malloc(sizeof(*new));
- if (new == NULL)
- return got_error_from_errno("malloc");
- new->path = path;
- new->path_len = strlen(path);
- new->data = data;
- TAILQ_INSERT_TAIL(pathlist, new, entry);
return NULL;
}
blob - 25f3858f09dbd0bc936d97fc851892955ecf6623
blob + ba76f7fe713a805f77718060b1d7ab0e18377246
--- lib/privsep.c
+++ lib/privsep.c
size_t datalen;
struct got_imsg_fetch_symrefs *isymrefs = NULL;
size_t n, remain;
+ struct got_pathlist_entry *new;
off_t off;
int i;
}
off += s->target_len;
remain -= s->target_len;
- err = got_pathlist_append(symrefs, name, target);
- if (err) {
+ err = got_pathlist_insert(&new, symrefs, name, target);
+ if (err || new == NULL) {
free(name);
free(target);
- goto done;
+ if (err->code != GOT_ERR_REF_DUP_ENTRY)
+ goto done;
}
}
break;
blob - 99f0df084a62eddfcd9809402c5834ffea4040f3
blob + e3ccf0e40499cc4a59881e8b6acb10735537f667
--- lib/repository.c
+++ lib/repository.c
break;
}
- err = got_pathlist_append(packidx_paths, path_packidx, NULL);
+ err = got_pathlist_insert(NULL, packidx_paths, path_packidx, NULL);
if (err)
break;
}
blob - 407601bbacc042b33ad5cb1d87afa5beeb6f6a9d
blob + 474f10b7b33e56c98f899f81d1428e5bae6a73db
--- lib/worktree.c
+++ lib/worktree.c
}
if (got_path_is_child(ie->path, a->parent_path, a->parent_len))
- err = got_pathlist_append(a->children, ie->path, NULL);
+ err = got_pathlist_insert(NULL, a->children, ie->path, NULL);
return err;
}
abspath = NULL;
}
- err = got_pathlist_append(added_paths, wt_path, NULL);
+ err = got_pathlist_insert(NULL, added_paths, wt_path, NULL);
if (err)
goto done;
wt_path = NULL;
blob - da97321077d9a4c57c2b10105cd568a1bc9c944e
blob + ff9e14244e355ede244af59ba841dcc1f03dd8fd
--- lib/worktree_cvg.c
+++ lib/worktree_cvg.c
}
if (got_path_is_child(ie->path, a->parent_path, a->parent_len))
- err = got_pathlist_append(a->children, ie->path, NULL);
+ err = got_pathlist_insert(NULL, a->children, ie->path, NULL);
return err;
}
goto done;
}
- err = got_pathlist_append(&commit_reflist, commit_refname,
+ err = got_pathlist_insert(&pe, &commit_reflist, commit_refname,
head_refname);
if (err)
goto done;
blob - 6ec79e85a76b5ba40ce146e249e75e24f79d7df9
blob + 7a03f43fd34cc5b92ead9494b1c592a98b9b4c0b
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
struct got_imsg_fetch_wanted_branch wbranch;
struct got_imsg_fetch_wanted_ref wref;
size_t datalen, i;
+ struct got_pathlist_entry *new;
char *remote_head = NULL, *worktree_branch = NULL;
#if 0
static int attached;
goto done;
}
memcpy(id, &href.id, sizeof(*id));
- err = got_pathlist_append(&have_refs, refname, id);
- if (err) {
+ err = got_pathlist_insert(&new, &have_refs, refname, id);
+ if (err || new == NULL) {
free(refname);
free(id);
- goto done;
+ if (err)
+ goto done;
}
imsg_free(&imsg);
goto done;
}
- err = got_pathlist_append(&wanted_branches, refname, NULL);
- if (err) {
+ err = got_pathlist_insert(&new, &wanted_branches, refname, NULL);
+ if (err || new == NULL) {
free(refname);
- goto done;
+ if (err)
+ goto done;
}
imsg_free(&imsg);
goto done;
}
- err = got_pathlist_append(&wanted_refs, refname, NULL);
+ err = got_pathlist_insert(NULL, &wanted_refs, refname, NULL);
if (err) {
free(refname);
goto done;
blob - 2a2c22971801db07832f237f3969bc2e90a0c745
blob + 766bbf50e670a6b1b65024ee61042ffb95cc792b
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
if (err)
goto done;
- err = got_pathlist_append(&their_refs, refname, id);
- if (err)
- goto done;
+ err = got_pathlist_insert(&pe, &their_refs, refname, id);
+ if (err || pe == NULL) {
+ free(refname);
+ free(id);
+ if (err)
+ goto done;
+ }
+
if (chattygot)
fprintf(stderr, "%s: remote has %s %s\n",
getprogname(), refname, id_str);
for (i = 0; i < send_req.nrefs; i++) {
struct got_object_id *id;
char *refname;
+ struct got_pathlist_entry *new;
if ((err = got_privsep_recv_imsg(&imsg, &ibuf, 0)) != 0) {
if (err->code == GOT_ERR_PRIVSEP_PIPE)
}
memcpy(id, &href.id, sizeof(*id));
if (href.delete)
- err = got_pathlist_append(&delete_refs, refname, id);
+ err = got_pathlist_insert(&new, &delete_refs, refname, id);
else
- err = got_pathlist_append(&refs, refname, id);
- if (err) {
+ err = got_pathlist_insert(&new, &refs, refname, id);
+ if (err || new == NULL ) {
free(refname);
free(id);
- goto done;
+ if (err)
+ goto done;
}
imsg_free(&imsg);
blob - 1c4930ff5c3ba4b4981d6378462f6c9d4d4c92da
blob + 2d847c25d775f95fe1aae56d8b6124dc1fd6d468
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
got ref -l -r $testroot/repo-clone > $testroot/stdout
- echo "HEAD: refs/heads/foo" > $testroot/stdout.expected
+ echo "HEAD: refs/heads/bar" > $testroot/stdout.expected
echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected
echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/bar: $commit_id" \
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
- branch { "foo" "bar" }
+ branch { "bar" "foo" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = refs/heads/foo:refs/remotes/origin/foo
fetch = refs/heads/bar:refs/remotes/origin/bar
+ fetch = refs/heads/foo:refs/remotes/origin/foo
fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
blob - 59243b5c07792da8486b3128282d07cd79ae5bbe
blob + 79d34d5be8de2f8a77dd949ec12828120cf67461
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
changed epsilon into file
- D epsilon/zeta
A epsilon
+ D epsilon/zeta
EOF