@@ -176,26 +176,34 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
176
176
}
177
177
178
178
static int do_serialize = 0 ;
179
+ static char * serialize_path = NULL ;
180
+
179
181
static int do_implicit_deserialize = 0 ;
180
182
static int do_explicit_deserialize = 0 ;
181
183
static char * deserialize_path = NULL ;
182
184
183
185
/*
184
- * --serialize | --serialize=1 | --serialize=v1
186
+ * --serialize | --serialize=<path>
187
+ *
188
+ * Request that we serialize status output rather than or in addition to
189
+ * printing in any of the established formats.
190
+ *
191
+ * Without a path, we write binary serialization data to stdout (and omit
192
+ * the normal status output).
185
193
*
186
- * Request that we serialize our output rather than printing in
187
- * any of the established formats. Optionally specify serialization
188
- * version.
194
+ * With a path, we write binary serialization data to the <path> and then
195
+ * write normal status output.
189
196
*/
190
197
static int opt_parse_serialize (const struct option * opt , const char * arg , int unset )
191
198
{
192
199
enum wt_status_format * value = (enum wt_status_format * )opt -> value ;
193
200
if (unset || !arg )
194
201
* value = STATUS_FORMAT_SERIALIZE_V1 ;
195
- else if (!strcmp (arg , "v1" ) || !strcmp (arg , "1" ))
196
- * value = STATUS_FORMAT_SERIALIZE_V1 ;
197
- else
198
- die ("unsupported serialize version '%s'" , arg );
202
+
203
+ if (arg ) {
204
+ free (serialize_path );
205
+ serialize_path = xstrdup (arg );
206
+ }
199
207
200
208
if (do_explicit_deserialize )
201
209
die ("cannot mix --serialize and --deserialize" );
@@ -1599,7 +1607,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1599
1607
N_ ("version" ), N_ ("machine-readable output" ),
1600
1608
PARSE_OPT_OPTARG , opt_parse_porcelain ),
1601
1609
{ OPTION_CALLBACK , 0 , "serialize" , & status_format ,
1602
- N_ ("version " ), N_ ("serialize raw status data to stdout" ),
1610
+ N_ ("path " ), N_ ("serialize raw status data to path or stdout" ),
1603
1611
PARSE_OPT_OPTARG | PARSE_OPT_NONEG , opt_parse_serialize },
1604
1612
{ OPTION_CALLBACK , 0 , "deserialize" , NULL ,
1605
1613
N_ ("path" ), N_ ("deserialize raw status data from file" ),
@@ -1725,6 +1733,16 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1725
1733
if (s .relative_paths )
1726
1734
s .prefix = prefix ;
1727
1735
1736
+ if (serialize_path ) {
1737
+ int fd_serialize = xopen (serialize_path ,
1738
+ O_WRONLY | O_CREAT | O_TRUNC , 0666 );
1739
+ if (fd_serialize < 0 )
1740
+ die_errno (_ ("could not serialize to '%s'" ),
1741
+ serialize_path );
1742
+ wt_status_serialize_v1 (fd_serialize , & s );
1743
+ close (fd_serialize );
1744
+ }
1745
+
1728
1746
wt_status_print (& s );
1729
1747
wt_status_collect_free_buffers (& s );
1730
1748
0 commit comments