commit-graph: add '--reachable' option
When writing commit-graph files, it can be convenient to ask for all reachable commits (starting at the ref set) in the resulting file. This is particularly helpful when writing to stdin is complicated, such as a future integration with 'git gc'. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d88b14b3fd
commit
59fb87701f
@ -7,6 +7,7 @@
|
||||
#include "packfile.h"
|
||||
#include "commit.h"
|
||||
#include "object.h"
|
||||
#include "refs.h"
|
||||
#include "revision.h"
|
||||
#include "sha1-lookup.h"
|
||||
#include "commit-graph.h"
|
||||
@ -656,6 +657,25 @@ static void compute_generation_numbers(struct packed_commit_list* commits)
|
||||
}
|
||||
}
|
||||
|
||||
static int add_ref_to_list(const char *refname,
|
||||
const struct object_id *oid,
|
||||
int flags, void *cb_data)
|
||||
{
|
||||
struct string_list *list = (struct string_list *)cb_data;
|
||||
|
||||
string_list_append(list, oid_to_hex(oid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void write_commit_graph_reachable(const char *obj_dir, int append)
|
||||
{
|
||||
struct string_list list;
|
||||
|
||||
string_list_init(&list, 1);
|
||||
for_each_ref(add_ref_to_list, &list);
|
||||
write_commit_graph(obj_dir, NULL, &list, append);
|
||||
}
|
||||
|
||||
void write_commit_graph(const char *obj_dir,
|
||||
struct string_list *pack_indexes,
|
||||
struct string_list *commit_hex,
|
||||
|
Reference in New Issue
Block a user