Fix 'git-crypt init' for newer versions of Git

At some point between Git 1.7.1 and Git 1.8.1.3, both 'git reset' and
'git status' stopped noticing that files were modified after their
smudge filter changed.  Consequentially, 'git reset --hard HEAD' would
not decrypt existing encrypted files in the repo.

This commit changes 'git-crypt init' to use 'git checkout -f HEAD
/top/of/repo' instead, which does the job.
This commit is contained in:
Andrew Ayer
2013-04-04 17:43:32 -07:00
parent e184b39eaa
commit b10fbcd299
3 changed files with 40 additions and 17 deletions

View File

@@ -40,7 +40,7 @@
#include <errno.h>
#include <fstream>
int exec_command (const char* command, std::string& output)
int exec_command (const char* command, std::ostream& output)
{
int pipefd[2];
if (pipe(pipefd) == -1) {
@@ -65,7 +65,7 @@ int exec_command (const char* command, std::string& output)
char buffer[1024];
ssize_t bytes_read;
while ((bytes_read = read(pipefd[0], buffer, sizeof(buffer))) > 0) {
output.append(buffer, bytes_read);
output.write(buffer, bytes_read);
}
close(pipefd[0]);
int status = 0;