commit - 9ffe20fdada0d0603909c9dee12683390d9f8570
commit + 7210b7156b950b1b2c0055beb00fab4b3e442317
blob - aa27a2d638ce25060a6d3de6eb3f8dc63a7b40aa
blob + 63211402e3c58b90e763fcef719e8632351dda88
--- got/got.c
+++ got/got.c
goto done;
for (;;) {
- struct got_object_id *id;
+ struct got_object_id id;
+
err = got_commit_graph_iter_next(&id, graph, repo,
check_cancelled, NULL);
if (err) {
break;
}
- if (id) {
- if (yca_id && got_object_id_cmp(id, yca_id) == 0)
- break;
- if (got_object_id_cmp(id, commit_id) == 0) {
- is_same_branch = 1;
- break;
- }
+ if (yca_id && got_object_id_cmp(&id, yca_id) == 0)
+ break;
+ if (got_object_id_cmp(&id, commit_id) == 0) {
+ is_same_branch = 1;
+ break;
}
}
done:
if (err)
goto done;
for (;;) {
- struct got_object_id *id;
+ struct got_object_id id;
if (sigint_received || sigpipe_received)
break;
err = NULL;
break;
}
- if (id == NULL)
- break;
- err = got_object_open_as_commit(&commit, repo, id);
+ err = got_object_open_as_commit(&commit, repo, &id);
if (err)
break;
}
if (search_pattern) {
- err = match_commit(&have_match, id, commit, ®ex);
+ err = match_commit(&have_match, &id, commit, ®ex);
if (err) {
got_object_commit_close(commit);
break;
match_changed_paths(&have_match,
&changed_paths, ®ex);
if (have_match == 0 && show_patch) {
- err = match_patch(&have_match, commit, id,
+ err = match_patch(&have_match, commit, &id,
path, diff_context, repo, ®ex,
tmpfile);
if (err)
}
if (reverse_display_order) {
- err = got_object_qid_alloc(&qid, id);
+ err = got_object_qid_alloc(&qid, &id);
if (err)
break;
STAILQ_INSERT_HEAD(&reversed_commits, qid, entry);
got_object_commit_close(commit);
} else {
if (one_line)
- err = print_commit_oneline(commit, id,
+ err = print_commit_oneline(commit, &id,
repo, refs_idmap);
else
- err = print_commit(commit, id, repo, path,
+ err = print_commit(commit, &id, repo, path,
show_changed_paths ? &changed_paths : NULL,
show_patch, diff_context, refs_idmap, NULL);
got_object_commit_close(commit);
break;
}
if ((limit && --limit == 0) ||
- (end_id && got_object_id_cmp(id, end_id) == 0))
+ (end_id && got_object_id_cmp(&id, end_id) == 0))
break;
TAILQ_FOREACH(pe, &changed_paths, entry) {
{
const struct got_error *err = NULL;
struct got_commit_graph *graph = NULL;
- struct got_object_id *parent_id = NULL;
+ struct got_object_id parent_id, commit_id;
struct got_object_qid *qid;
- struct got_object_id *commit_id = initial_commit_id;
- struct got_object_id *tmp = NULL;
err = got_commit_graph_open(&graph, "/", 1);
if (err)
check_cancelled, NULL);
if (err)
goto done;
- while (got_object_id_cmp(commit_id, iter_stop_id) != 0) {
+
+ memcpy(&commit_id, initial_commit_id, sizeof(commit_id));
+ while (got_object_id_cmp(&commit_id, iter_stop_id) != 0) {
err = got_commit_graph_iter_next(&parent_id, graph, repo,
check_cancelled, NULL);
if (err) {
}
goto done;
} else {
- err = check_path_prefix(parent_id, commit_id,
+ err = check_path_prefix(&parent_id, &commit_id,
path_prefix, path_prefix_errcode, repo);
if (err)
goto done;
- err = got_object_qid_alloc(&qid, commit_id);
+ err = got_object_qid_alloc(&qid, &commit_id);
if (err)
goto done;
STAILQ_INSERT_HEAD(commits, qid, entry);
- free(tmp);
- tmp = got_object_id_dup(parent_id);
- if (tmp == NULL) {
- err = got_error_from_errno(
- "got_object_id_dup");
- goto done;
- }
- commit_id = tmp;
+ memcpy(&commit_id, &parent_id, sizeof(commit_id));
}
}
done:
- free(tmp);
got_commit_graph_close(graph);
return err;
}
blob - c6db1d281f02e6030400a87b216c3aec949a37f9
blob + 0580992091e15b774b51ac00db28f4d691a4b1a0
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
static const struct got_error *
gw_get_commits(struct gw_trans * gw_trans, struct gw_header *header,
- int limit, struct got_object_id *id)
+ int limit, struct got_object_id *iter_start_id)
{
const struct got_error *error = NULL;
struct got_commit_graph *graph = NULL;
if (error)
return error;
- error = got_commit_graph_iter_start(graph, id, gw_trans->repo, NULL,
- NULL);
+ error = got_commit_graph_iter_start(graph, iter_start_id,
+ gw_trans->repo, NULL, NULL);
if (error)
goto err;
for (;;) {
+ struct got_object_id id;
+
error = got_commit_graph_iter_next(&id, graph, gw_trans->repo,
NULL, NULL);
if (error) {
error = NULL;
goto done;
}
- if (id == NULL)
- goto err;
-
- error = got_object_open_as_commit(&commit, gw_trans->repo, id);
+
+ error = got_object_open_as_commit(&commit, gw_trans->repo, &id);
if (error)
goto err;
if (limit == 1 && chk_multi == 0 &&
gw_trans->gw_conf->got_max_commits_display != 1) {
- error = gw_get_commit(gw_trans, header, commit, id);
+ error = gw_get_commit(gw_trans, header, commit, &id);
if (error)
goto err;
commit_found = 1;
if (error)
goto err;
- error = gw_get_commit(gw_trans, n_header, commit, id);
+ error = gw_get_commit(gw_trans, n_header, commit, &id);
if (error)
goto err;
got_ref_list_free(&n_header->refs);
blob - 4d1d0e1751dc02091b79eed65be347563e71679b
blob + 9238f92bb4af244b34cfd23e0764816063474c74
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
goto done;
for (;;) {
- struct got_object_id *next_id;
+ struct got_object_id next_id;
error = got_commit_graph_iter_next(&next_id, graph, repo, NULL,
NULL);
goto done;
}
- error = got_object_open_as_commit(&commit, repo, next_id);
+ error = got_object_open_as_commit(&commit, repo, &next_id);
if (error)
goto done;
goto done;
error = got_get_repo_commit(c, repo_commit, commit,
- &refs, next_id);
+ &refs, &next_id);
if (error) {
gotweb_free_repo_commit(repo_commit);
goto done;
blob - 617697ddc049b408054512990ba787719cfad80a
blob + 9f0a8aa211fe8d5dd0defcc6fe994cafada284c3
--- include/got_commit_graph.h
+++ include/got_commit_graph.h
const struct got_error *got_commit_graph_iter_start(
struct got_commit_graph *, struct got_object_id *, struct got_repository *,
got_cancel_cb, void *);
-const struct got_error *got_commit_graph_iter_next(struct got_object_id **,
+const struct got_error *got_commit_graph_iter_next(struct got_object_id *,
struct got_commit_graph *, struct got_repository *, got_cancel_cb, void *);
const struct got_error *got_commit_graph_intersect(struct got_object_id **,
struct got_commit_graph *, struct got_commit_graph *,
blob - 46796cfdc61a895985d270fcd52fa5ff3f3da374
blob + 531a4c6c7f0f7ee650c3ef2b49aa61e0a2865500
--- lib/blame.c
+++ lib/blame.c
struct got_object_id *obj_id = NULL;
struct got_blob_object *blob = NULL;
struct got_blame *blame = NULL;
- struct got_object_id *id = NULL;
- int lineno;
+ struct got_object_id id;
+ int lineno, have_id = 0;
struct got_commit_graph *graph = NULL;
*blamep = NULL;
if (err)
goto done;
for (;;) {
- struct got_object_id *next_id;
- err = got_commit_graph_iter_next(&next_id, graph, repo,
+ err = got_commit_graph_iter_next(&id, graph, repo,
cancel_cb, cancel_arg);
if (err) {
if (err->code == GOT_ERR_ITER_COMPLETED) {
}
goto done;
}
- if (next_id) {
- free(id);
- id = got_object_id_dup(next_id);
- if (id == NULL) {
- err = got_error_from_errno("got_object_id_dup");
- goto done;
- }
- err = blame_commit(blame, id, path, repo, cb, arg);
- if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED)
- err = NULL;
- goto done;
- }
- if (blame->nannotated == blame->nlines)
- break;
+ have_id = 1;
- err = flip_files(blame);
- if (err)
- goto done;
+ err = blame_commit(blame, &id, path, repo, cb, arg);
+ if (err) {
+ if (err->code == GOT_ERR_ITER_COMPLETED)
+ err = NULL;
+ goto done;
}
+ if (blame->nannotated == blame->nlines)
+ break;
+
+ err = flip_files(blame);
+ if (err)
+ goto done;
}
- if (id && blame->nannotated < blame->nlines) {
+ if (have_id && blame->nannotated < blame->nlines) {
/* Annotate remaining non-annotated lines with last commit. */
- err = got_object_open_as_commit(&last_commit, repo, id);
+ err = got_object_open_as_commit(&last_commit, repo, &id);
if (err)
goto done;
for (lineno = 0; lineno < blame->nlines; lineno++) {
- err = annotate_line(blame, lineno, last_commit, id,
+ err = annotate_line(blame, lineno, last_commit, &id,
cb, arg);
if (err)
goto done;
if (graph)
got_commit_graph_close(graph);
free(obj_id);
- free(id);
if (blob)
got_object_blob_close(blob);
if (start_commit)
blob - 69e0e7352395e10354f4f67c96c98956bf34910f
blob + ae0d1c4a107ec6772002d0f5ae5e06b426fe3afe
--- lib/commit_graph.c
+++ lib/commit_graph.c
* commit timestmap.
*/
struct got_commit_graph_iter_list iter_list;
-
- /*
- * Temporary storage for the id returned by
- * got_commit_graph_iter_next.
- */
- struct got_object_id id;
};
static const struct got_error *
}
const struct got_error *
-got_commit_graph_iter_next(struct got_object_id **id,
+got_commit_graph_iter_next(struct got_object_id *id,
struct got_commit_graph *graph, struct got_repository *repo,
got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
struct got_commit_graph_node *node;
-
- *id = NULL;
node = TAILQ_FIRST(&graph->iter_list);
if (node == NULL) {
return err;
}
- memcpy(&graph->id, &node->id, sizeof(graph->id));
- *id = &graph->id;
+ memcpy(id, &node->id, sizeof(*id));
TAILQ_REMOVE(&graph->iter_list, node, entry);
free(node);
return NULL;
+}
+
+static const struct got_error *
+find_yca_add_id(struct got_object_id **yca_id, struct got_commit_graph *graph,
+ struct got_object_idset *commit_ids, struct got_repository *repo,
+ got_cancel_cb cancel_cb, void *cancel_arg)
+{
+ const struct got_error *err = NULL;
+ struct got_object_id id;
+
+ err = got_commit_graph_iter_next(&id, graph, repo, cancel_cb,
+ cancel_arg);
+ if (err)
+ return err;
+
+ if (got_object_idset_contains(commit_ids, &id)) {
+ *yca_id = got_object_id_dup(&id);
+ if (*yca_id == NULL)
+ err = got_error_from_errno("got_object_id_dup");
+ return err;
+ }
+
+ return got_object_idset_add(commit_ids, &id, NULL);
}
const struct got_error *
goto done;
for (;;) {
- struct got_object_id *id = NULL, *id2 = NULL;
-
if (cancel_cb) {
err = (*cancel_cb)(cancel_arg);
if (err)
}
if (!completed) {
- err = got_commit_graph_iter_next(&id, graph, repo,
+ err = find_yca_add_id(yca_id, graph, commit_ids, repo,
cancel_cb, cancel_arg);
if (err) {
if (err->code != GOT_ERR_ITER_COMPLETED)
err = NULL;
completed = 1;
}
+ if (*yca_id)
+ break;
}
if (!completed2) {
- err = got_commit_graph_iter_next(&id2, graph2, repo,
+ err = find_yca_add_id(yca_id, graph2, commit_ids, repo,
cancel_cb, cancel_arg);
if (err) {
if (err->code != GOT_ERR_ITER_COMPLETED)
err = NULL;
completed2 = 1;
}
- }
-
- if (id) {
- if (got_object_idset_contains(commit_ids, id)) {
- *yca_id = got_object_id_dup(id);
- if (*yca_id)
- break;
- err = got_error_from_errno("got_object_id_dup");
+ if (*yca_id)
break;
-
- }
- err = got_object_idset_add(commit_ids, id, NULL);
- if (err)
- break;
}
- if (id2) {
- if (got_object_idset_contains(commit_ids, id2)) {
- *yca_id = got_object_id_dup(id2);
- if (*yca_id)
- break;
- err = got_error_from_errno("got_object_id_dup");
- break;
- }
- err = got_object_idset_add(commit_ids, id2, NULL);
- if (err)
- break;
- }
-
if (completed && completed2) {
err = got_error(GOT_ERR_ANCESTRY);
break;
}
-
}
done:
got_object_idset_free(commit_ids);
blob - e3dfe0b0fa8499bd5718d635b375246f49a08b43
blob + fbd2faaa3e696de2d13ced3ff97602a0846b85fd
--- tog/tog.c
+++ tog/tog.c
* while updating the display.
*/
do {
- struct got_object_id *id;
+ struct got_object_id id;
struct got_commit_object *commit;
struct commit_queue_entry *entry;
int errcode;
err = got_commit_graph_iter_next(&id, a->graph, a->repo,
NULL, NULL);
- if (err || id == NULL)
+ if (err)
break;
- err = got_object_open_as_commit(&commit, a->repo, id);
+ err = got_object_open_as_commit(&commit, a->repo, &id);
if (err)
break;
- entry = alloc_commit_queue_entry(commit, id);
+ entry = alloc_commit_queue_entry(commit, &id);
if (entry == NULL) {
err = got_error_from_errno("alloc_commit_queue_entry");
break;
if (*a->searching == TOG_SEARCH_FORWARD &&
!*a->search_next_done) {
int have_match;
- err = match_commit(&have_match, id, commit, a->regex);
+ err = match_commit(&have_match, &id, commit, a->regex);
if (err)
break;
if (have_match)