diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-09 17:35:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-09 19:36:31 -0700 |
commit | 5ec0dbbce831c53550e3d58a0f1b39d14dd8097f (patch) | |
tree | c4d6e3465f8c52beb398023c2a2ad33fd7459052 /save-git.c | |
parent | 1e8c8283963131c3b3e5f61942c38caa7d321ed1 (diff) | |
download | subsurface-5ec0dbbce831c53550e3d58a0f1b39d14dd8097f.tar.gz |
git save format: add dive computer nicknames and firmware details
This adds a top-level "00-Subsurface" file that sorts first in the git
tree, and contains version information, dive computer nicknames and
settings. Although right now the settings are just the autogroup thing.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-git.c')
-rw-r--r-- | save-git.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/save-git.c b/save-git.c index c47638b8e..990364eba 100644 --- a/save-git.c +++ b/save-git.c @@ -664,12 +664,49 @@ static struct dir *mktree(struct dir *dir, const char *fmt, ...) return subdir; } +static void save_one_device(void *_b, const char *model, uint32_t deviceid, + const char *nickname, const char *serial, const char *firmware) +{ + struct membuffer *b = _b; + + if (nickname && !strcmp(model, nickname)) + nickname = NULL; + if (serial && !*serial) serial = NULL; + if (firmware && !*firmware) firmware = NULL; + if (nickname && !*nickname) nickname = NULL; + if (!nickname && !serial && !firmware) + return; + + show_utf8(b, "divecomputerid ", model, ""); + put_format(b, " deviceid=%08x", deviceid); + show_utf8(b, " serial=", serial, ""); + show_utf8(b, " firmware=", firmware, ""); + show_utf8(b, " nickname=", nickname, ""); + put_string(b, "\n"); +} + +#define VERSION 2 + +static void save_settings(git_repository *repo, struct dir *tree) +{ + struct membuffer b = { 0 }; + + show_utf8(&b, "subsurface ", VERSION_STRING, "\n"); + put_format(&b, "version %d\n", VERSION); + call_for_each_dc(&b, save_one_device); + cond_put_format(autogroup, &b, "autogroup\n"); + + blob_insert(repo, tree, &b, "00-Subsurface"); +} + static int create_git_tree(git_repository *repo, struct dir *root, bool select_only) { int i; struct dive *dive; dive_trip_t *trip; + save_settings(repo, root); + for (trip = dive_trip_list; trip != NULL; trip = trip->next) trip->index = 0; |