1010static char const * const builtin_commit_graph_usage [] = {
1111 N_ ("git commit-graph [--object-dir <objdir>]" ),
1212 N_ ("git commit-graph read [--object-dir <objdir>]" ),
13- N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow]" ),
14- N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] <split options>" ),
13+ N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress] " ),
14+ N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>" ),
1515 NULL
1616};
1717
1818static const char * const builtin_commit_graph_verify_usage [] = {
19- N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow]" ),
19+ N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress] " ),
2020 NULL
2121};
2222
@@ -26,7 +26,7 @@ static const char * const builtin_commit_graph_read_usage[] = {
2626};
2727
2828static const char * const builtin_commit_graph_write_usage [] = {
29- N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] <split options>" ),
29+ N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>" ),
3030 NULL
3131};
3232
@@ -38,6 +38,7 @@ static struct opts_commit_graph {
3838 int append ;
3939 int split ;
4040 int shallow ;
41+ int progress ;
4142} opts ;
4243
4344static int graph_verify (int argc , const char * * argv )
@@ -55,9 +56,11 @@ static int graph_verify(int argc, const char **argv)
5556 N_ ("The object directory to store the graph" )),
5657 OPT_BOOL (0 , "shallow" , & opts .shallow ,
5758 N_ ("if the commit-graph is split, only verify the tip file" )),
59+ OPT_BOOL (0 , "progress" , & opts .progress , N_ ("force progress reporting" )),
5860 OPT_END (),
5961 };
6062
63+ opts .progress = isatty (2 );
6164 argc = parse_options (argc , argv , NULL ,
6265 builtin_commit_graph_verify_options ,
6366 builtin_commit_graph_verify_usage , 0 );
@@ -66,7 +69,9 @@ static int graph_verify(int argc, const char **argv)
6669 opts .obj_dir = get_object_directory ();
6770 if (opts .shallow )
6871 flags |= COMMIT_GRAPH_VERIFY_SHALLOW ;
69-
72+ if (opts .progress )
73+ flags |= COMMIT_GRAPH_WRITE_PROGRESS ;
74+
7075 graph_name = get_commit_graph_filename (opts .obj_dir );
7176 open_ok = open_commit_graph (graph_name , & fd , & st );
7277 if (!open_ok && errno != ENOENT )
@@ -154,7 +159,7 @@ static int graph_write(int argc, const char **argv)
154159 struct string_list * commit_hex = NULL ;
155160 struct string_list lines ;
156161 int result = 0 ;
157- enum commit_graph_write_flags flags = COMMIT_GRAPH_WRITE_PROGRESS ;
162+ enum commit_graph_write_flags flags = 0 ;
158163
159164 static struct option builtin_commit_graph_write_options [] = {
160165 OPT_STRING (0 , "object-dir" , & opts .obj_dir ,
@@ -168,6 +173,7 @@ static int graph_write(int argc, const char **argv)
168173 N_ ("start walk at commits listed by stdin" )),
169174 OPT_BOOL (0 , "append" , & opts .append ,
170175 N_ ("include all commits already in the commit-graph file" )),
176+ OPT_BOOL (0 , "progress" , & opts .progress , N_ ("force progress reporting" )),
171177 OPT_BOOL (0 , "split" , & opts .split ,
172178 N_ ("allow writing an incremental commit-graph file" )),
173179 OPT_INTEGER (0 , "max-commits" , & split_opts .max_commits ,
@@ -179,6 +185,7 @@ static int graph_write(int argc, const char **argv)
179185 OPT_END (),
180186 };
181187
188+ opts .progress = isatty (2 );
182189 split_opts .size_multiple = 2 ;
183190 split_opts .max_commits = 0 ;
184191 split_opts .expire_time = 0 ;
@@ -195,6 +202,8 @@ static int graph_write(int argc, const char **argv)
195202 flags |= COMMIT_GRAPH_WRITE_APPEND ;
196203 if (opts .split )
197204 flags |= COMMIT_GRAPH_WRITE_SPLIT ;
205+ if (opts .progress )
206+ flags |= COMMIT_GRAPH_WRITE_PROGRESS ;
198207
199208 read_replace_refs = 0 ;
200209
0 commit comments