diff --git a/src/redis-check-aof.c b/src/redis-check-aof.c index a3da79dd438..46d05a42c65 100644 --- a/src/redis-check-aof.c +++ b/src/redis-check-aof.c @@ -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]; @@ -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")) {