1
#include "git-compat-util.h"
2
+#include "bloom.h"
3
#include "builtin.h"
4
+#include "commit-graph.h"
5
#include "commit.h"
6
#include "config.h"
7
#include "diff.h"
20
struct last_modified_entry {
21
struct hashmap_entry hashent;
22
struct object_id oid;
23
+ struct bloom_key key;
24
const char path[FLEX_ARRAY];
25
};
26
45
46
static void last_modified_release(struct last_modified *lm)
47
{
48
+ struct hashmap_iter iter;
49
+ struct last_modified_entry *ent;
50
+
51
+ hashmap_for_each_entry(&lm->paths, &iter, ent, hashent)
52
+ bloom_key_clear(&ent->key);
53
+
54
hashmap_clear_and_free(&lm->paths, struct last_modified_entry, hashent);
55
release_revisions(&lm->rev);
56
}
72
73
FLEX_ALLOC_STR(ent, path, path);
74
oidcpy(&ent->oid, &p->two->oid);
75
+ if (lm->rev.bloom_filter_settings)
76
+ bloom_key_fill(&ent->key, path, strlen(path),
77
+ lm->rev.bloom_filter_settings);
78
hashmap_entry_init(&ent->hashent, strhash(ent->path));
79
hashmap_add(&lm->paths, &ent->hashent);
80
}
151
last_modified_emit(data->lm, path, data->commit);
152
153
hashmap_remove(&data->lm->paths, &ent->hashent, path);
154
+ bloom_key_clear(&ent->key);
155
free(ent);
156
}
157
195
}
196
}
197
198
+static bool maybe_changed_path(struct last_modified *lm, struct commit *origin)
199
+{
200
+ struct bloom_filter *filter;
201
+ struct last_modified_entry *ent;
202
+ struct hashmap_iter iter;
203
+
204
+ if (!lm->rev.bloom_filter_settings)
205
+ return true;
206
+
207
+ if (commit_graph_generation(origin) == GENERATION_NUMBER_INFINITY)
208
+ return true;
209
+
210
+ filter = get_bloom_filter(lm->rev.repo, origin);
211
+ if (!filter)
212
+ return true;
213
+
214
+ hashmap_for_each_entry(&lm->paths, &iter, ent, hashent) {
215
+ if (bloom_filter_contains(filter, &ent->key,
216
+ lm->rev.bloom_filter_settings))
217
+ return true;
218
+ }
219
+ return false;
220
+}
221
+
222
static int last_modified_run(struct last_modified *lm)
223
{
224
struct last_modified_callback_data data = { .lm = lm };
239
&data.commit->object.oid, "",
240
&lm->rev.diffopt);
241
diff_flush(&lm->rev.diffopt);
205
- } else {
206
- log_tree_commit(&lm->rev, data.commit);
242
+
243
+ break;
244
}
245
+
246
+ if (!maybe_changed_path(lm, data.commit))
247
+ continue;
248
+
249
+ log_tree_commit(&lm->rev, data.commit);
250
}
251
252
return 0;
273
return argc;
274
}
275
276
+ lm->rev.bloom_filter_settings = get_bloom_filter_settings(lm->rev.repo);
277
+
278
if (populate_paths_from_revs(lm) < 0)
279
return error(_("unable to setup last-modified"));
280