Re: [PATCH v4 07/13] commit-graph: implement --set-latest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/22/2018 1:31 PM, Junio C Hamano wrote:
Derrick Stolee <stolee@xxxxxxxxx> 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.

Perhaps the 'write' subcommand should be replaced with 'replace' which does the following:

1. Write a new commit graph based on the starting commits (from all packs, from specified packs, from OIDs).
2. Update 'graph-latest' to point to that new file.
3. Delete all "expired" commit graph files.

(Hence, we would drop the "--set-latest" and "--delete-expired" options.)

Due to the concerns with concurrency, I really don't want to split these operations into independent processes that consumers need to call in series. Since this sequence of events is the only real interaction we expect (for now), this interface will simplify the design.

The biggest reason I didn't design it like this in the first place is that the behavior changes as the patch develops.

Thanks,
-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux