From 92c6375c50d56c9ca3cc2f336a5f286e259a6037 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 10 May 2011 15:00:58 -0700 Subject: [PATCH] Remove the unused git_revision() The use of this function had been commented out for some time now, and it contained an unescaped call to popen. Rather than trying to fix dead code, just remove it altogether. --- hash.cxx | 7 ------- util.cxx | 27 --------------------------- util.h | 1 - 3 files changed, 35 deletions(-) diff --git a/hash.cxx b/hash.cxx index 28c64279a..7c4dbee8b 100644 --- a/hash.cxx +++ b/hash.cxx @@ -154,13 +154,6 @@ get_base_hash (systemtap_session& s) h.add_path(s.kernel_build_tree + "/include/linux/version.h"); h.add_path(s.kernel_build_tree + "/include/linux/utsrelease.h"); - // If the kernel is a git working directory, then add the git HEAD - // revision to our hash as well. - // XXX avoiding this for now, because it's potentially expensive and has - // uncertain gain. The only corner case that this may help is if a developer - // is switching the source tree without rebuilding the kernel... - ///h.add(git_revision(s.kernel_build_tree)); - // Hash runtime path (that gets added in as "-R path"). h.add_path(s.runtime_path); diff --git a/util.cxx b/util.cxx index bd73d7664..92ea09e52 100644 --- a/util.cxx +++ b/util.cxx @@ -409,33 +409,6 @@ cmdstr_join(const vector& cmds) } -string -git_revision(const string& path) -{ - string revision = "(not-a-git-repository)"; - string git_dir = path + "/.git/"; - - struct stat st; - if (stat(git_dir.c_str(), &st) == 0) - { - string command = "git --git-dir=\"" + git_dir - + "\" rev-parse HEAD 2>/dev/null"; - - char buf[50]; - FILE *fp = popen(command.c_str(), "r"); - if (fp != NULL) - { - char *bufp = fgets(buf, sizeof(buf), fp); - int rc = pclose(fp); - if (bufp != NULL && rc == 0) - revision = buf; - } - } - - return revision; -} - - // XXX written only from the main thread, but can be read in a // signal handler. synchronization needed? static set spawned_pids; diff --git a/util.h b/util.h index 3926ca962..9ee331bf5 100644 --- a/util.h +++ b/util.h @@ -42,7 +42,6 @@ std::string find_executable(const std::string& name, const std::string& env_path = "PATH"); const std::string cmdstr_quoted(const std::string& cmd); const std::string cmdstr_join(const std::vector& cmds); -std::string git_revision(const std::string& path); int stap_waitpid(int verbose, pid_t pid); pid_t stap_spawn(int verbose, const std::vector& args); pid_t stap_spawn_piped(int verbose, const std::vector& args, -- 2.43.5