Don't grant write permissions when cloning git repo

It should be unnecessary, the read-only flag is set on packfiles by Git
and doesn't cause problems deleting the folder normally, and someone's
reported an error when granting permissions.
This commit is contained in:
Oliver Hamlet
2018-09-24 19:31:45 +01:00
parent 3a747b804e
commit ba90657b0c
2 changed files with 1 additions and 39 deletions
+1 -38
View File
@@ -38,19 +38,6 @@ namespace fs = boost::filesystem;
namespace loot {
GitHelper::GitHelper() : logger_(getLogger()) {}
GitHelper::~GitHelper() {
if (data_.repo != nullptr) {
std::string path = git_repository_path(data_.repo);
if (!path.empty()) {
try {
GrantWritePermissions(path);
} catch (std::exception&) {
}
}
}
}
GitHelper::GitData::GitData() :
repo(nullptr),
remote(nullptr),
@@ -164,26 +151,6 @@ bool GitHelper::IsRepository(const boost::filesystem::path& path) {
NULL) == 0;
}
// Removes the read-only flag from some files in git repositories created by
// libgit2.
void GitHelper::GrantWritePermissions(const boost::filesystem::path& path) {
if (logger_) {
logger_->trace("Recursively setting write permission on directory: {}",
path.string());
}
for (fs::recursive_directory_iterator it(path);
it != fs::recursive_directory_iterator();
++it) {
if ((it->status().permissions() &
(fs::owner_write | fs::group_write | fs::others_write)) == 0) {
if (logger_) {
logger_->trace("Setting write permission for: {}", it->path().string());
}
fs::permissions(it->path(), fs::add_perms | fs::owner_write);
}
}
}
int GitHelper::DiffFileCallback(const git_diff_delta* delta,
float progress,
void* payload) {
@@ -248,13 +215,9 @@ void GitHelper::Clone(const boost::filesystem::path& path,
if (logger_) {
logger_->trace(
"Target repo path not empty, renaming and moving previous content "
"back in.");
"Target repo path not empty, moving cloned files in.");
}
GrantWritePermissions(path);
GrantWritePermissions(repoPath);
std::vector<boost::filesystem::path> filenamesToMove;
for (fs::directory_iterator it(repoPath);
it != fs::directory_iterator();
-1
View File
@@ -35,7 +35,6 @@ namespace loot {
class GitHelper {
public:
GitHelper();
~GitHelper();
void InitialiseOptions(const std::string& branch,
const std::string& filenameToCheckout);