@@ -167,26 +167,34 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
167
167
}
168
168
169
169
static int do_serialize = 0 ;
170
+ static char * serialize_path = NULL ;
171
+
170
172
static int do_implicit_deserialize = 0 ;
171
173
static int do_explicit_deserialize = 0 ;
172
174
static char * deserialize_path = NULL ;
173
175
174
176
/*
175
- * --serialize | --serialize=1 | --serialize=v1
177
+ * --serialize | --serialize=<path>
178
+ *
179
+ * Request that we serialize status output rather than or in addition to
180
+ * printing in any of the established formats.
181
+ *
182
+ * Without a path, we write binary serialization data to stdout (and omit
183
+ * the normal status output).
176
184
*
177
- * Request that we serialize our output rather than printing in
178
- * any of the established formats. Optionally specify serialization
179
- * version.
185
+ * With a path, we write binary serialization data to the <path> and then
186
+ * write normal status output.
180
187
*/
181
188
static int opt_parse_serialize (const struct option * opt , const char * arg , int unset )
182
189
{
183
190
enum wt_status_format * value = (enum wt_status_format * )opt -> value ;
184
191
if (unset || !arg )
185
192
* value = STATUS_FORMAT_SERIALIZE_V1 ;
186
- else if (!strcmp (arg , "v1" ) || !strcmp (arg , "1" ))
187
- * value = STATUS_FORMAT_SERIALIZE_V1 ;
188
- else
189
- die ("unsupported serialize version '%s'" , arg );
193
+
194
+ if (arg ) {
195
+ free (serialize_path );
196
+ serialize_path = xstrdup (arg );
197
+ }
190
198
191
199
if (do_explicit_deserialize )
192
200
die ("cannot mix --serialize and --deserialize" );
@@ -1634,7 +1642,7 @@ struct repository *repo UNUSED)
1634
1642
N_ ("version" ), N_ ("machine-readable output" ),
1635
1643
PARSE_OPT_OPTARG , opt_parse_porcelain ),
1636
1644
OPT_CALLBACK_F (0 , "serialize" , & status_format ,
1637
- N_ ("version " ), N_ ("serialize raw status data to stdout" ),
1645
+ N_ ("path " ), N_ ("serialize raw status data to path or stdout" ),
1638
1646
PARSE_OPT_OPTARG | PARSE_OPT_NONEG , opt_parse_serialize ),
1639
1647
OPT_CALLBACK_F (0 , "deserialize" , NULL ,
1640
1648
N_ ("path" ), N_ ("deserialize raw status data from file" ),
@@ -1777,6 +1785,16 @@ struct repository *repo UNUSED)
1777
1785
if (s .relative_paths )
1778
1786
s .prefix = prefix ;
1779
1787
1788
+ if (serialize_path ) {
1789
+ int fd_serialize = xopen (serialize_path ,
1790
+ O_WRONLY | O_CREAT | O_TRUNC , 0666 );
1791
+ if (fd_serialize < 0 )
1792
+ die_errno (_ ("could not serialize to '%s'" ),
1793
+ serialize_path );
1794
+ wt_status_serialize_v1 (fd_serialize , & s );
1795
+ close (fd_serialize );
1796
+ }
1797
+
1780
1798
wt_status_print (& s );
1781
1799
wt_status_collect_free_buffers (& s );
1782
1800
0 commit comments