sequencer.c: use commit-slab to mark seen 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>
Nguyễn Thái Ngọc Duy committed
May 19, 2018 at 07:28 UTC
8315bd20eac098fa39f1c642e2df4f81949051cf
1 file changed
+9
-3
sequencer.c
+9
-3
@@ -23,6 +23,7 @@
23
#include "hashmap.h"
24
#include "notes-utils.h"
25
#include "sigchain.h"
26
+#include "commit-slab.h"
27
28
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
29
@@ -3160,6 +3161,7 @@ static enum check_level get_missing_commit_check_level(void)
3161
return CHECK_IGNORE;
3162
}
3163
3164
+define_commit_slab(commit_seen, unsigned char);
3165
/*
3166
* Check if the user dropped some commits by mistake
3167
* Behaviour determined by rebase.missingCommitsCheck.
@@ -3173,6 +3175,9 @@ int check_todo_list(void)
3175
struct todo_list todo_list = TODO_LIST_INIT;
3176
struct strbuf missing = STRBUF_INIT;
3177
int advise_to_edit_todo = 0, res = 0, i;
3178
+ struct commit_seen commit_seen;
3179
+
3180
+ init_commit_seen(&commit_seen);
3181
3182
strbuf_addstr(&todo_file, rebase_path_todo());
3183
if (strbuf_read_file_or_whine(&todo_list.buf, todo_file.buf) < 0) {
@@ -3189,7 +3194,7 @@ int check_todo_list(void)
3194
for (i = 0; i < todo_list.nr; i++) {
3195
struct commit *commit = todo_list.items[i].commit;
3196
if (commit)
3192
- commit->util = (void *)1;
3197
+ *commit_seen_at(&commit_seen, commit) = 1;
3198
}
3199
3200
todo_list_release(&todo_list);
@@ -3205,11 +3210,11 @@ int check_todo_list(void)
3210
for (i = todo_list.nr - 1; i >= 0; i--) {
3211
struct todo_item *item = todo_list.items + i;
3212
struct commit *commit = item->commit;
3208
- if (commit && !commit->util) {
3213
+ if (commit && !*commit_seen_at(&commit_seen, commit)) {
3214
strbuf_addf(&missing, " - %s %.*s\n",
3215
short_commit_name(commit),
3216
item->arg_len, item->arg);
3212
- commit->util = (void *)1;
3217
+ *commit_seen_at(&commit_seen, commit) = 1;
3218
}
3219
}
3220
@@ -3235,6 +3240,7 @@ int check_todo_list(void)
3240
"The possible behaviours are: ignore, warn, error.\n\n"));
3241
3242
leave_check:
3243
+ clear_commit_seen(&commit_seen);
3244
strbuf_release(&todo_file);
3245
todo_list_release(&todo_list);
3246