Derrick Stolee <sto...@gmail.com> writes:

>  static struct opts_commit_graph {
>       const char *obj_dir;
>       const char *graph_file;
> +     int set_latest;
>  } opts;
> ...
> @@ -89,6 +106,8 @@ static int graph_write(int argc, const char **argv)
>               { OPTION_STRING, 'o', "object-dir", &opts.obj_dir,
>                       N_("dir"),
>                       N_("The object directory to store the graph") },
> +             OPT_BOOL('u', "set-latest", &opts.set_latest,
> +                     N_("update graph-head to written graph file")),
>               OPT_END(),
>       };
>  
> @@ -102,6 +121,9 @@ static int graph_write(int argc, const char **argv)
>       graph_name = write_commit_graph(opts.obj_dir);
>  
>       if (graph_name) {
> +             if (opts.set_latest)
> +                     set_latest_file(opts.obj_dir, graph_name);
> +

This feels like a very strange API from potential caller's point of
view.  Because you have to decide that you are going to mark it as
the latest one upfront before actually writing the graph file, if
you forget to pass --set-latest, you have to know how to manually
mark the file as latest anyway.  I would understand if it were one
of the following:

 (1) whenever a new commit graph file is written in the
     objects/info/ directory, always mark it as the latest (drop
     --set-latest option altogether); or

 (2) make set-latest command that takes a name of an existing graph
     file in the objects/info/ directory, and sets the latest
     pointer to point at it (make it separate from 'write' command).

though.

Reply via email to