|
17 | 17 | #include "mailmap.h" |
18 | 18 | #include "commit-slab.h" |
19 | 19 | #include "dir.h" |
| 20 | +#include "cache-tree.h" |
20 | 21 |
|
21 | 22 | volatile show_early_output_fn_t show_early_output; |
22 | 23 |
|
@@ -1303,6 +1304,53 @@ void add_reflogs_to_pending(struct rev_info *revs, unsigned flags) |
1303 | 1304 | for_each_reflog(handle_one_reflog, &cb); |
1304 | 1305 | } |
1305 | 1306 |
|
| 1307 | +static void add_cache_tree(struct cache_tree *it, struct rev_info *revs, |
| 1308 | + struct strbuf *path) |
| 1309 | +{ |
| 1310 | + size_t baselen = path->len; |
| 1311 | + int i; |
| 1312 | + |
| 1313 | + if (it->entry_count >= 0) { |
| 1314 | + struct tree *tree = lookup_tree(it->sha1); |
| 1315 | + add_pending_object_with_path(revs, &tree->object, "", |
| 1316 | + 040000, path->buf); |
| 1317 | + } |
| 1318 | + |
| 1319 | + for (i = 0; i < it->subtree_nr; i++) { |
| 1320 | + struct cache_tree_sub *sub = it->down[i]; |
| 1321 | + strbuf_addf(path, "%s%s", baselen ? "/" : "", sub->name); |
| 1322 | + add_cache_tree(sub->cache_tree, revs, path); |
| 1323 | + strbuf_setlen(path, baselen); |
| 1324 | + } |
| 1325 | + |
| 1326 | +} |
| 1327 | + |
| 1328 | +void add_index_objects_to_pending(struct rev_info *revs, unsigned flags) |
| 1329 | +{ |
| 1330 | + int i; |
| 1331 | + |
| 1332 | + read_cache(); |
| 1333 | + for (i = 0; i < active_nr; i++) { |
| 1334 | + struct cache_entry *ce = active_cache[i]; |
| 1335 | + struct blob *blob; |
| 1336 | + |
| 1337 | + if (S_ISGITLINK(ce->ce_mode)) |
| 1338 | + continue; |
| 1339 | + |
| 1340 | + blob = lookup_blob(ce->sha1); |
| 1341 | + if (!blob) |
| 1342 | + die("unable to add index blob to traversal"); |
| 1343 | + add_pending_object_with_path(revs, &blob->object, "", |
| 1344 | + ce->ce_mode, ce->name); |
| 1345 | + } |
| 1346 | + |
| 1347 | + if (active_cache_tree) { |
| 1348 | + struct strbuf path = STRBUF_INIT; |
| 1349 | + add_cache_tree(active_cache_tree, revs, &path); |
| 1350 | + strbuf_release(&path); |
| 1351 | + } |
| 1352 | +} |
| 1353 | + |
1306 | 1354 | static int add_parents_only(struct rev_info *revs, const char *arg_, int flags) |
1307 | 1355 | { |
1308 | 1356 | unsigned char sha1[20]; |
@@ -1653,6 +1701,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg |
1653 | 1701 | !strcmp(arg, "--reflog") || !strcmp(arg, "--not") || |
1654 | 1702 | !strcmp(arg, "--no-walk") || !strcmp(arg, "--do-walk") || |
1655 | 1703 | !strcmp(arg, "--bisect") || starts_with(arg, "--glob=") || |
| 1704 | + !strcmp(arg, "--indexed-objects") || |
1656 | 1705 | starts_with(arg, "--exclude=") || |
1657 | 1706 | starts_with(arg, "--branches=") || starts_with(arg, "--tags=") || |
1658 | 1707 | starts_with(arg, "--remotes=") || starts_with(arg, "--no-walk=")) |
@@ -2082,6 +2131,8 @@ static int handle_revision_pseudo_opt(const char *submodule, |
2082 | 2131 | clear_ref_exclusion(&revs->ref_excludes); |
2083 | 2132 | } else if (!strcmp(arg, "--reflog")) { |
2084 | 2133 | add_reflogs_to_pending(revs, *flags); |
| 2134 | + } else if (!strcmp(arg, "--indexed-objects")) { |
| 2135 | + add_index_objects_to_pending(revs, *flags); |
2085 | 2136 | } else if (!strcmp(arg, "--not")) { |
2086 | 2137 | *flags ^= UNINTERESTING | BOTTOM; |
2087 | 2138 | } else if (!strcmp(arg, "--no-walk")) { |
|
0 commit comments