diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp index 14532e927..745a29ee0 100644 --- a/src/tools/genrevision/genrevision.cpp +++ b/src/tools/genrevision/genrevision.cpp @@ -79,8 +79,7 @@ bool extractDataFromGit(std::string filename, std::string path, bool url, RawDat { char buf[1024]; - FILE* entriesFile = fopen(filename.c_str(), "r"); - if (entriesFile) + if (FILE* entriesFile = fopen(filename.c_str(), "r")) { char hash_str[200]; char branch_str[200]; @@ -112,7 +111,7 @@ bool extractDataFromGit(std::string filename, std::string path, bool url, RawDat char* acc_str = NULL; char* repo_str = NULL; - // parse URL like git@github.com:mangoszero/server + // parse URL like git@github.com:mangosthree/server char url_buf[200]; int res = sscanf(url_str, "git@%s", url_buf); if (res) @@ -142,47 +141,42 @@ bool extractDataFromGit(std::string filename, std::string path, bool url, RawDat else { strcpy(data.rev_str, hash_str); } } - else + else if (entriesFile = fopen((path + ".git/HEAD").c_str(), "r")) { - entriesFile = fopen((path + ".git/HEAD").c_str(), "r"); - if(entriesFile) + if (!fgets(buf, sizeof(buf), entriesFile)) { - if (!fgets(buf, sizeof(buf), entriesFile)) - { - fclose(entriesFile); - return false; - } - - char refBuff[200]; - if (!sscanf(buf, "ref: %s", refBuff)) - { - fclose(entriesFile); - return false; - } - fclose(entriesFile); + return false; + } - FILE *refFile = fopen((path + ".git/" + refBuff).c_str(), "r"); - if (refFile) + char refBuff[200]; + if (!sscanf(buf, "ref: %s", refBuff)) + { + fclose(entriesFile); + return false; + } + + fclose(entriesFile); + + if (FILE *refFile = fopen((path + ".git/" + refBuff).c_str(), "r")) + { + char hash[41]; + + if (!fgets(hash, sizeof(hash), refFile)) { - char hash[41]; - - if (!fgets(hash, sizeof(hash), refFile)) - { - fclose(refFile); - return false; - } - - strcpy(data.rev_str, hash); - fclose(refFile); + return false; } - else - { return false; } + + strcpy(data.rev_str, hash); + + fclose(refFile); } else { return false; } } + else + return false; time_t rev_time = 0; // extracting date/time