mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Add --version support for redis-check-rdb (#9971)
Let's you see which version of redis this tool is part of (similarly to redis-cli and redis-benchmark)
This commit is contained in:
parent
1b0968df46
commit
23b6173486
@ -357,6 +357,20 @@ err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static sds checkRdbVersion(void) {
|
||||
sds version;
|
||||
version = sdscatprintf(sdsempty(), "%s", REDIS_VERSION);
|
||||
|
||||
/* Add git commit and working tree status when available */
|
||||
if (strtoll(redisGitSHA1(),NULL,16)) {
|
||||
version = sdscatprintf(version, " (git:%s", redisGitSHA1());
|
||||
if (strtoll(redisGitDirty(),NULL,10))
|
||||
version = sdscatprintf(version, "-dirty");
|
||||
version = sdscat(version, ")");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/* RDB check main: called form server.c when Redis is executed with the
|
||||
* redis-check-rdb alias, on during RDB loading errors.
|
||||
*
|
||||
@ -375,6 +389,11 @@ int redis_check_rdb_main(int argc, char **argv, FILE *fp) {
|
||||
if (argc != 2 && fp == NULL) {
|
||||
fprintf(stderr, "Usage: %s <rdb-file-name>\n", argv[0]);
|
||||
exit(1);
|
||||
} else if (!strcmp(argv[1],"-v") || !strcmp(argv[1], "--version")) {
|
||||
sds version = checkRdbVersion();
|
||||
printf("redis-check-rdb %s\n", version);
|
||||
sdsfree(version);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user