From 689fe36030537ab57d3a5a1a55baf86675d5ecdb Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 6 Mar 2014 13:28:39 -0800 Subject: Initial implementation of git save format This saves the dive data into a git object repository instead of a single XML file. We create a git object tree with each dive as a separate file, hierarchically by trip and date. NOTE 1: This largely duplicates the XML saving code, because trying to share it seemed just too painful: the logic is very similar, but the details of the actual strings end up differing sufficiently that there are tons of trivial differences. The git save format is line-based with minimal quoting, while XML quotes everything with either "<..\>" or using single quotes around attributes. NOTE 2: You currently need a dummy "file" to save to, which points to the real save location: the git repository and branch to be used. We should make this a config thing, but for testing, do something like this: echo git /home/torvalds/scuba:linus > git-test to create that git information file, and when you use "Save To" and specify "git-test" as the file to save to, subsurface will use the new git save logic to save to the branch "linus" in the repository found at "/home/torvalds/scuba". NOTE 3: The git save format uses just the git object directory, it does *not* check out the result in any git working tree or index. So after you do a save, you can do git log -p linus to see what actually happened in that branch, but it will not affect any actual checked-out state in the repository. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- dive.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'dive.c') diff --git a/dive.c b/dive.c index 0552c31da..a402f9932 100644 --- a/dive.c +++ b/dive.c @@ -224,6 +224,30 @@ void copy_events(struct dive *s, struct dive *d) } } +int nr_cylinders(struct dive *dive) +{ + int nr; + + for (nr = MAX_CYLINDERS; nr; --nr) { + cylinder_t *cylinder = dive->cylinder + nr - 1; + if (!cylinder_nodata(cylinder)) + break; + } + return nr; +} + +int nr_weightsystems(struct dive *dive) +{ + int nr; + + for (nr = MAX_WEIGHTSYSTEMS; nr; --nr) { + weightsystem_t *ws = dive->weightsystem + nr - 1; + if (!weightsystem_none(ws)) + break; + } + return nr; +} + void copy_cylinders(struct dive *s, struct dive *d) { int i; -- cgit v1.2.3-70-g09d2