summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-05-19 05:28:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-21 05:07:20 (GMT)
commit3cc0287b394bf802af68d4fdb8c18e16318df907 (patch)
treea48b82472ee8461320fcd61b410e52d3f431f739 /sequencer.c
parent8315bd20eac098fa39f1c642e2df4f81949051cf (diff)
downloadgit-3cc0287b394bf802af68d4fdb8c18e16318df907.zip
git-3cc0287b394bf802af68d4fdb8c18e16318df907.tar.gz
git-3cc0287b394bf802af68d4fdb8c18e16318df907.tar.bz2
sequencer.c: use commit-slab to associate todo items to commits
It's done so that commit->util can be removed. See more explanation in the commit that removes commit->util. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c
index 3af296d..3b6d56d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3362,6 +3362,8 @@ static int subject2item_cmp(const void *fndata,
return key ? strcmp(a->subject, key) : strcmp(a->subject, b->subject);
}
+define_commit_slab(commit_todo_item, struct todo_item *);
+
/*
* Rearrange the todo list that has both "pick commit-id msg" and "pick
* commit-id fixup!/squash! msg" in it so that the latter is put immediately
@@ -3378,6 +3380,7 @@ int rearrange_squash(void)
struct hashmap subject2item;
int res = 0, rearranged = 0, *next, *tail, i;
char **subjects;
+ struct commit_todo_item commit_todo;
if (strbuf_read_file_or_whine(&todo_list.buf, todo_file) < 0)
return -1;
@@ -3386,6 +3389,7 @@ int rearrange_squash(void)
return -1;
}
+ init_commit_todo_item(&commit_todo);
/*
* The hashmap maps onelines to the respective todo list index.
*
@@ -3416,10 +3420,11 @@ int rearrange_squash(void)
if (is_fixup(item->command)) {
todo_list_release(&todo_list);
+ clear_commit_todo_item(&commit_todo);
return error(_("the script was already rearranged."));
}
- item->commit->util = item;
+ *commit_todo_item_at(&commit_todo, item->commit) = item;
parse_commit(item->commit);
commit_buffer = get_commit_buffer(item->commit, NULL);
@@ -3446,9 +3451,9 @@ int rearrange_squash(void)
else if (!strchr(p, ' ') &&
(commit2 =
lookup_commit_reference_by_name(p)) &&
- commit2->util)
+ *commit_todo_item_at(&commit_todo, commit2))
/* found by commit name */
- i2 = (struct todo_item *)commit2->util
+ i2 = *commit_todo_item_at(&commit_todo, commit2)
- todo_list.items;
else {
/* copy can be a prefix of the commit subject */
@@ -3527,5 +3532,6 @@ int rearrange_squash(void)
hashmap_free(&subject2item, 1);
todo_list_release(&todo_list);
+ clear_commit_todo_item(&commit_todo);
return res;
}