mirror of
https://github.com/AGWA/git-crypt.git
synced 2025-12-31 15:07:40 -08:00
git-crypt init: Ignore untracked files when running git status
Untracked files are not touched by git reset, so git-crypt init is safe even with untracked files present. This relies on the -u option to git-status, which was added in Git 1.6.0, which was released in 2008. Add Git 1.6.0 as a requirement in the README.
This commit is contained in:
1
README
1
README
@@ -31,6 +31,7 @@ DEPENDENCIES
|
||||
|
||||
To use git-crypt, you need:
|
||||
|
||||
* Git 1.6.0 or later
|
||||
* OpenSSL
|
||||
* For decrypted git diff output, Git 1.6.1 or later
|
||||
* For decrypted git blame output, Git 1.7.2 or later
|
||||
|
||||
@@ -195,10 +195,13 @@ void init (const char* argv0, const char* keyfile)
|
||||
// 0. Check to see if HEAD exists. See below why we do this.
|
||||
bool head_exists = system("git rev-parse HEAD >/dev/null 2>/dev/null") == 0;
|
||||
|
||||
// 1. Make sure working directory is clean
|
||||
// 1. Make sure working directory is clean (ignoring untracked files)
|
||||
// We do this because we run 'git reset --hard HEAD' later and we don't
|
||||
// want the user to lose any changes. 'git reset' doesn't touch
|
||||
// untracked files so it's safe to ignore those.
|
||||
int status;
|
||||
std::string status_output;
|
||||
status = exec_command("git status --porcelain", status_output);
|
||||
status = exec_command("git status -uno --porcelain", status_output);
|
||||
if (status != 0) {
|
||||
std::clog << "git status failed - is this a git repository?\n";
|
||||
std::exit(1);
|
||||
|
||||
Reference in New Issue
Block a user