@@ -144,26 +144,31 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
144144}
145145
146146static int do_serialize = 0 ;
147+ static char * serialize_path = NULL ;
148+
147149static int do_implicit_deserialize = 0 ;
148150static int do_explicit_deserialize = 0 ;
149151static char * deserialize_path = NULL ;
150152
151153/*
152- * --serialize | --serialize=1 | --serialize=v1
154+ * --serialize | --serialize=<path>
155+ *
156+ * Request that we serialize status output rather than or in addition to
157+ * printing in any of the established formats.
158+ *
159+ * Without a path, we write binary serialization data to stdout (and omit
160+ * the normal status output).
153161 *
154- * Request that we serialize our output rather than printing in
155- * any of the established formats. Optionally specify serialization
156- * version.
162+ * With a path, we write binary serialization data to the <path> and then
163+ * write normal status output.
157164 */
158165static int opt_parse_serialize (const struct option * opt , const char * arg , int unset )
159166{
160167 enum wt_status_format * value = (enum wt_status_format * )opt -> value ;
161168 if (unset || !arg )
162169 * value = STATUS_FORMAT_SERIALIZE_V1 ;
163- else if (!strcmp (arg , "v1" ) || !strcmp (arg , "1" ))
164- * value = STATUS_FORMAT_SERIALIZE_V1 ;
165- else
166- die ("unsupported serialize version '%s'" , arg );
170+
171+ serialize_path = xstrdup_or_null (arg );
167172
168173 if (do_explicit_deserialize )
169174 die ("cannot mix --serialize and --deserialize" );
@@ -1418,7 +1423,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
14181423 N_ ("version" ), N_ ("machine-readable output" ),
14191424 PARSE_OPT_OPTARG , opt_parse_porcelain },
14201425 { OPTION_CALLBACK , 0 , "serialize" , & status_format ,
1421- N_ ("version " ), N_ ("serialize raw status data to stdout" ),
1426+ N_ ("path " ), N_ ("serialize raw status data to path or stdout" ),
14221427 PARSE_OPT_OPTARG | PARSE_OPT_NONEG , opt_parse_serialize },
14231428 { OPTION_CALLBACK , 0 , "deserialize" , NULL ,
14241429 N_ ("path" ), N_ ("deserialize raw status data from file" ),
@@ -1560,6 +1565,16 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15601565 if (s .relative_paths )
15611566 s .prefix = prefix ;
15621567
1568+ if (serialize_path ) {
1569+ int fd_serialize = xopen (serialize_path ,
1570+ O_WRONLY | O_CREAT | O_TRUNC , 0666 );
1571+ if (fd_serialize < 0 )
1572+ die_errno (_ ("could not serialize to '%s'" ),
1573+ serialize_path );
1574+ wt_status_serialize_v1 (fd_serialize , & s );
1575+ close (fd_serialize );
1576+ }
1577+
15631578 wt_status_print (& s );
15641579 wt_status_collect_free_buffers (& s );
15651580
0 commit comments