mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Git storage: change time encoding in directory names
We used to use [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex] in our git storage format for directory that contained dives. Problem with the is that on Windows the colon ':' is an illegal character in a filename. So libgit2 refuses to clone such a repository on Windows. So instead we now always write dive directories in git repositories as [[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex] which replaces the ':' with an '='. Of course we load / parse both formats so that older formats still work. The next time they are written all the names change which causes rather huge commits, but that's the only way I see for cloud storage to work on Windows. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
845030a8ad
commit
56b82e0ecf
2 changed files with 7 additions and 5 deletions
|
@ -1129,7 +1129,8 @@ static int dive_trip_directory(const char *root, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dive directory, name is [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex],
|
* Dive directory, name is [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex] in older git repositories
|
||||||
|
* but [[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex] in newer repos as ':' is an illegal character for Windows files
|
||||||
* and 'timeoff' points to what should be the time part of
|
* and 'timeoff' points to what should be the time part of
|
||||||
* the name (the first digit of the hour).
|
* the name (the first digit of the hour).
|
||||||
*
|
*
|
||||||
|
@ -1156,8 +1157,8 @@ static int dive_directory(const char *root, const char *name, int timeoff)
|
||||||
if (mday_off < 0)
|
if (mday_off < 0)
|
||||||
return GIT_WALK_SKIP;
|
return GIT_WALK_SKIP;
|
||||||
|
|
||||||
/* Get the time of day */
|
/* Get the time of day -- parse both time formats so we can read old repos when not on Windows */
|
||||||
if (sscanf(name+timeoff, "%d:%d:%d", &h, &m, &s) != 3)
|
if (sscanf(name+timeoff, "%d:%d:%d", &h, &m, &s) != 3 && sscanf(name+timeoff, "%d=%d=%d", &h, &m, &s) != 3)
|
||||||
return GIT_WALK_SKIP;
|
return GIT_WALK_SKIP;
|
||||||
if (!validate_time(h, m, s))
|
if (!validate_time(h, m, s))
|
||||||
return GIT_WALK_SKIP;
|
return GIT_WALK_SKIP;
|
||||||
|
@ -1307,7 +1308,7 @@ static int walk_tree_directory(const char *root, const git_tree_entry *entry)
|
||||||
* We know the len is at least 3, because we had at least
|
* We know the len is at least 3, because we had at least
|
||||||
* two digits and a dash
|
* two digits and a dash
|
||||||
*/
|
*/
|
||||||
if (name[len-3] == ':')
|
if (name[len-3] == ':' || name[len-3] == '=')
|
||||||
return dive_directory(root, name, len-8);
|
return dive_directory(root, name, len-8);
|
||||||
|
|
||||||
if (digits != 2)
|
if (digits != 2)
|
||||||
|
|
|
@ -549,7 +549,8 @@ static void create_dive_name(struct dive *dive, struct membuffer *name, struct t
|
||||||
if (tm.tm_mon != dirtm->tm_mon)
|
if (tm.tm_mon != dirtm->tm_mon)
|
||||||
put_format(name, "%02u-", tm.tm_mon+1);
|
put_format(name, "%02u-", tm.tm_mon+1);
|
||||||
|
|
||||||
put_format(name, "%02u-%s-%02u:%02u:%02u",
|
/* a colon is an illegal char in a file name on Windows - use an '=' instead */
|
||||||
|
put_format(name, "%02u-%s-%02u=%02u=%02u",
|
||||||
tm.tm_mday, weekday[tm.tm_wday],
|
tm.tm_mday, weekday[tm.tm_wday],
|
||||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue