Skip to content

Commit

Permalink
Add --version support for redis-check-aof
Browse files Browse the repository at this point in the history
Let us see which version of redis this tool is part of.
Similarly to redis-cli, redis-benchmark and redis-check-rdb
  • Loading branch information
enjoy-binbin committed Jun 13, 2022
1 parent abb2ea7 commit ffab059
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/redis-check-aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,20 @@ void checkOldStyleAof(char *filepath, int fix, int preamble) {
}
}

static sds checkAofVersion(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;
}

int redis_check_aof_main(int argc, char **argv) {
char *filepath;
char temp_filepath[PATH_MAX + 1];
Expand All @@ -528,6 +542,13 @@ int redis_check_aof_main(int argc, char **argv) {
if (argc < 2) {
goto invalid_args;
} else if (argc == 2) {
if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) {
sds version = checkAofVersion();
printf("redis-check-aof %s\n", version);
sdsfree(version);
exit(0);
}

filepath = argv[1];
} else if (argc == 3) {
if (!strcmp(argv[1], "--fix")) {
Expand Down

0 comments on commit ffab059

Please sign in to comment.