6
6
#include "repository.h"
7
7
#include "commit-graph.h"
8
8
#include "object-store.h"
9
+ #include "unistd.h"
9
10
10
11
static char const * const builtin_commit_graph_usage [] = {
11
12
N_ ("git commit-graph [--object-dir <objdir>]" ),
12
13
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>" ),
14
+ N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress] " ),
15
+ N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>" ),
15
16
NULL
16
17
};
17
18
18
19
static const char * const builtin_commit_graph_verify_usage [] = {
19
- N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow]" ),
20
+ N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress] " ),
20
21
NULL
21
22
};
22
23
@@ -26,7 +27,7 @@ static const char * const builtin_commit_graph_read_usage[] = {
26
27
};
27
28
28
29
static 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>" ),
30
+ N_ ("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>" ),
30
31
NULL
31
32
};
32
33
@@ -38,6 +39,7 @@ static struct opts_commit_graph {
38
39
int append ;
39
40
int split ;
40
41
int shallow ;
42
+ int progress ;
41
43
} opts ;
42
44
43
45
static int graph_verify (int argc , const char * * argv )
@@ -48,16 +50,20 @@ static int graph_verify(int argc, const char **argv)
48
50
int fd ;
49
51
struct stat st ;
50
52
int flags = 0 ;
51
-
53
+ int defaultProgressState = isatty (2 );
54
+
52
55
static struct option builtin_commit_graph_verify_options [] = {
53
56
OPT_STRING (0 , "object-dir" , & opts .obj_dir ,
54
57
N_ ("dir" ),
55
58
N_ ("The object directory to store the graph" )),
56
59
OPT_BOOL (0 , "shallow" , & opts .shallow ,
57
60
N_ ("if the commit-graph is split, only verify the tip file" )),
61
+ OPT_BOOL (0 , "progress" , & opts .progress , N_ ("force progress reporting" )),
58
62
OPT_END (),
59
63
};
60
64
65
+ opts .progress = defaultProgressState ;
66
+
61
67
argc = parse_options (argc , argv , NULL ,
62
68
builtin_commit_graph_verify_options ,
63
69
builtin_commit_graph_verify_usage , 0 );
@@ -66,7 +72,9 @@ static int graph_verify(int argc, const char **argv)
66
72
opts .obj_dir = get_object_directory ();
67
73
if (opts .shallow )
68
74
flags |= COMMIT_GRAPH_VERIFY_SHALLOW ;
69
-
75
+ if (opts .progress )
76
+ flags |= COMMIT_GRAPH_PROGRESS ;
77
+
70
78
graph_name = get_commit_graph_filename (opts .obj_dir );
71
79
open_ok = open_commit_graph (graph_name , & fd , & st );
72
80
if (!open_ok && errno != ENOENT )
@@ -154,8 +162,9 @@ static int graph_write(int argc, const char **argv)
154
162
struct string_list * commit_hex = NULL ;
155
163
struct string_list lines ;
156
164
int result = 0 ;
157
- unsigned int flags = COMMIT_GRAPH_PROGRESS ;
158
-
165
+ unsigned int flags = 0 ;
166
+ int defaultProgressState = isatty (2 );
167
+
159
168
static struct option builtin_commit_graph_write_options [] = {
160
169
OPT_STRING (0 , "object-dir" , & opts .obj_dir ,
161
170
N_ ("dir" ),
@@ -168,6 +177,7 @@ static int graph_write(int argc, const char **argv)
168
177
N_ ("start walk at commits listed by stdin" )),
169
178
OPT_BOOL (0 , "append" , & opts .append ,
170
179
N_ ("include all commits already in the commit-graph file" )),
180
+ OPT_BOOL (0 , "progress" , & opts .progress , N_ ("force progress reporting" )),
171
181
OPT_BOOL (0 , "split" , & opts .split ,
172
182
N_ ("allow writing an incremental commit-graph file" )),
173
183
OPT_INTEGER (0 , "max-commits" , & split_opts .max_commits ,
@@ -179,6 +189,7 @@ static int graph_write(int argc, const char **argv)
179
189
OPT_END (),
180
190
};
181
191
192
+ opts .progress = defaultProgressState ;
182
193
split_opts .size_multiple = 2 ;
183
194
split_opts .max_commits = 0 ;
184
195
split_opts .expire_time = 0 ;
@@ -195,6 +206,8 @@ static int graph_write(int argc, const char **argv)
195
206
flags |= COMMIT_GRAPH_APPEND ;
196
207
if (opts .split )
197
208
flags |= COMMIT_GRAPH_SPLIT ;
209
+ if (opts .progress )
210
+ flags |= COMMIT_GRAPH_PROGRESS ;
198
211
199
212
read_replace_refs = 0 ;
200
213
0 commit comments