Skip to content

Commit d38e07b

Browse files
garimasi514gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Garima Singh <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1217c03 commit d38e07b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Documentation/git-commit-graph.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ or `--stdin-packs`.)
5757
With the `--append` option, include all commits that are present in the
5858
existing commit-graph file.
5959
+
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+
+
6065
With the `--split` option, write the commit-graph as a chain of multiple
6166
commit-graph files stored in `<dir>/info/commit-graphs`. The new commits
6267
not already in the commit-graph are added in a new "tip" file. This file

builtin/commit-graph.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
static char const * const builtin_commit_graph_usage[] = {
1111
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>"),
1313
NULL
1414
};
1515

@@ -19,7 +19,7 @@ static const char * const builtin_commit_graph_verify_usage[] = {
1919
};
2020

2121
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>"),
2323
NULL
2424
};
2525

@@ -32,6 +32,7 @@ static struct opts_commit_graph {
3232
int split;
3333
int shallow;
3434
int progress;
35+
int enable_changed_paths;
3536
} opts;
3637

3738
static struct object_directory *find_odb(struct repository *r,
@@ -135,6 +136,8 @@ static int graph_write(int argc, const char **argv)
135136
N_("start walk at commits listed by stdin")),
136137
OPT_BOOL(0, "append", &opts.append,
137138
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")),
138141
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
139142
OPT_BOOL(0, "split", &opts.split,
140143
N_("allow writing an incremental commit-graph file")),
@@ -168,6 +171,8 @@ static int graph_write(int argc, const char **argv)
168171
flags |= COMMIT_GRAPH_WRITE_SPLIT;
169172
if (opts.progress)
170173
flags |= COMMIT_GRAPH_WRITE_PROGRESS;
174+
if (opts.enable_changed_paths)
175+
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
171176

172177
read_replace_refs = 0;
173178
odb = find_odb(the_repository, opts.obj_dir);

0 commit comments

Comments
 (0)