Re: [PATCH 04/12] sequencer.c: use commit-slab to mark seen commits

2018-05-12 Thread Duy Nguyen
On Sat, May 12, 2018 at 3:43 PM, Junio C Hamano  wrote:
> Jeff King  writes:
>
>> On Sat, May 12, 2018 at 10:00:20AM +0200, Nguyễn Thái Ngọc Duy wrote:
>>
>>> +define_commit_slab(commit_seen, int);
>>
>> Yay, this one is nice and simple. :) This is what I had hoped for all
>> along with the slab concept.
>>
>> -Peff
>
> Does it need to use a full int, not just a byte per commit, though?

True. Is it time to introduce 'bool' type? I did not want to put the
'char' type up there (but now that I think about it I could have put
uint8_t too).
-- 
Duy


Re: [PATCH 04/12] sequencer.c: use commit-slab to mark seen commits

2018-05-12 Thread Junio C Hamano
Jeff King  writes:

> On Sat, May 12, 2018 at 10:00:20AM +0200, Nguyễn Thái Ngọc Duy wrote:
>
>> +define_commit_slab(commit_seen, int);
>
> Yay, this one is nice and simple. :) This is what I had hoped for all
> along with the slab concept.
>
> -Peff

Does it need to use a full int, not just a byte per commit, though?


Re: [PATCH 04/12] sequencer.c: use commit-slab to mark seen commits

2018-05-12 Thread Jeff King
On Sat, May 12, 2018 at 10:00:20AM +0200, Nguyễn Thái Ngọc Duy wrote:

> +define_commit_slab(commit_seen, int);

Yay, this one is nice and simple. :) This is what I had hoped for all
along with the slab concept.

-Peff


[PATCH 04/12] sequencer.c: use commit-slab to mark seen commits

2018-05-12 Thread Nguyễn Thái Ngọc Duy
It's done so that commit->util can be removed. See more explanation in
the commit that removes commit->util.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 sequencer.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 4ce5120e77..5993ffe060 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -23,6 +23,7 @@
 #include "hashmap.h"
 #include "notes-utils.h"
 #include "sigchain.h"
+#include "commit-slab.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
@@ -3160,6 +3161,7 @@ static enum check_level 
get_missing_commit_check_level(void)
return CHECK_IGNORE;
 }
 
+define_commit_slab(commit_seen, int);
 /*
  * Check if the user dropped some commits by mistake
  * Behaviour determined by rebase.missingCommitsCheck.
@@ -3173,6 +3175,9 @@ int check_todo_list(void)
struct todo_list todo_list = TODO_LIST_INIT;
struct strbuf missing = STRBUF_INIT;
int advise_to_edit_todo = 0, res = 0, i;
+   struct commit_seen commit_seen;
+
+   init_commit_seen(_seen);
 
strbuf_addstr(_file, rebase_path_todo());
if (strbuf_read_file_or_whine(_list.buf, todo_file.buf) < 0) {
@@ -3189,7 +3194,7 @@ int check_todo_list(void)
for (i = 0; i < todo_list.nr; i++) {
struct commit *commit = todo_list.items[i].commit;
if (commit)
-   commit->util = (void *)1;
+   *commit_seen_at(_seen, commit) = 1;
}
 
todo_list_release(_list);
@@ -3205,11 +3210,11 @@ int check_todo_list(void)
for (i = todo_list.nr - 1; i >= 0; i--) {
struct todo_item *item = todo_list.items + i;
struct commit *commit = item->commit;
-   if (commit && !commit->util) {
+   if (commit && !*commit_seen_at(_seen, commit)) {
strbuf_addf(, " - %s %.*s\n",
short_commit_name(commit),
item->arg_len, item->arg);
-   commit->util = (void *)1;
+   *commit_seen_at(_seen, commit) = 1;
}
}
 
@@ -3235,6 +3240,7 @@ int check_todo_list(void)
"The possible behaviours are: ignore, warn, error.\n\n"));
 
 leave_check:
+   clear_commit_seen(_seen);
strbuf_release(_file);
todo_list_release(_list);
 
-- 
2.17.0.705.g3525833791