mirror of
https://git.zx2c4.com/cgit
synced 2025-07-19 18:34:46 +02:00
Refactor snapshot support
The snapshot support needs to be split between output- and config-related functions to get the layering between shared.c and ui-*.c right. There is also some codestyle-issues which needs fixing to make the snapshot functions more similar to the rest of the cgit code. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
parent
e0e4478e7b
commit
f34478cbe0
4 changed files with 91 additions and 87 deletions
27
shared.c
27
shared.c
|
@ -479,3 +479,30 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn)
|
|||
old_sha1 = commit->parents->item->object.sha1;
|
||||
cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL);
|
||||
}
|
||||
|
||||
int cgit_parse_snapshots_mask(const char *str)
|
||||
{
|
||||
const struct cgit_snapshot_format *f;
|
||||
static const char *delim = " \t,:/|;";
|
||||
int tl, sl, rv = 0;
|
||||
|
||||
/* favor legacy setting */
|
||||
if(atoi(str))
|
||||
return 1;
|
||||
for(;;) {
|
||||
str += strspn(str,delim);
|
||||
tl = strcspn(str,delim);
|
||||
if (!tl)
|
||||
break;
|
||||
for (f = cgit_snapshot_formats; f->suffix; f++) {
|
||||
sl = strlen(f->suffix);
|
||||
if((tl == sl && !strncmp(f->suffix, str, tl)) ||
|
||||
(tl == sl-1 && !strncmp(f->suffix+1, str, tl-1))) {
|
||||
rv |= f->bit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
str += tl;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue