commit-graph: add --changed-paths option to write subcommand
Add --changed-paths option to git commit-graph write. This option will allow users to compute information about the paths that have changed between a commit and its first parent, and write it into the commit graph file. If the option is passed to the write subcommand we set the COMMIT_GRAPH_WRITE_BLOOM_FILTERS flag and pass it down to the commit-graph logic. Helped-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Garima Singh <garima.singh@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Garima Singh committed
Apr 6, 2020 at 16:59 UTC
d38e07b8c44ffdb73e7eba1b7f6a73eb7eb0d5f9
2 files changed
+12
-2
Documentation/git-commit-graph.txt
+5
@@ -57,6 +57,11 @@ or `--stdin-packs`.)
57
With the `--append` option, include all commits that are present in the
58
existing commit-graph file.
59
+
60
+With the `--changed-paths` option, compute and write information about the
61
+paths changed between a commit and it's first parent. This operation can
62
+take a while on large repositories. It provides significant performance gains
63
+for getting history of a directory or a file with `git log -- <path>`.
64
++
65
With the `--split` option, write the commit-graph as a chain of multiple
66
commit-graph files stored in `<dir>/info/commit-graphs`. The new commits
67
not already in the commit-graph are added in a new "tip" file. This file
builtin/commit-graph.c
+7
-2
@@ -9,7 +9,7 @@
9
10
static char const * const builtin_commit_graph_usage[] = {
11
N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]"),
12
- N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>"),
12
+ N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--changed-paths] [--[no-]progress] <split options>"),
13
NULL
14
};
15
@@ -19,7 +19,7 @@ static const char * const builtin_commit_graph_verify_usage[] = {
19
};
20
21
static const char * const builtin_commit_graph_write_usage[] = {
22
- N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>"),
22
+ N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--changed-paths] [--[no-]progress] <split options>"),
23
NULL
24
};
25
@@ -32,6 +32,7 @@ static struct opts_commit_graph {
32
int split;
33
int shallow;
34
int progress;
35
+ int enable_changed_paths;
36
} opts;
37
38
static struct object_directory *find_odb(struct repository *r,
@@ -135,6 +136,8 @@ static int graph_write(int argc, const char **argv)
136
N_("start walk at commits listed by stdin")),
137
OPT_BOOL(0, "append", &opts.append,
138
N_("include all commits already in the commit-graph file")),
139
+ OPT_BOOL(0, "changed-paths", &opts.enable_changed_paths,
140
+ N_("enable computation for changed paths")),
141
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
142
OPT_BOOL(0, "split", &opts.split,
143
N_("allow writing an incremental commit-graph file")),
@@ -168,6 +171,8 @@ static int graph_write(int argc, const char **argv)
171
flags |= COMMIT_GRAPH_WRITE_SPLIT;
172
if (opts.progress)
173
flags |= COMMIT_GRAPH_WRITE_PROGRESS;
174
+ if (opts.enable_changed_paths)
175
+ flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
176
177
read_replace_refs = 0;
178
odb = find_odb(the_repository, opts.obj_dir);