mirror of
https://github.com/AGWA/git-crypt.git
synced 2026-01-06 10:05:47 -08:00
init: skip git reset if HEAD doesn't exist
This could happen if repo is brand-new with no files.
This commit is contained in:
@@ -170,7 +170,9 @@ void init (const char* argv0, const char* keyfile)
|
|||||||
|
|
||||||
// 3. Do a hard reset so any files that were previously checked out encrypted
|
// 3. Do a hard reset so any files that were previously checked out encrypted
|
||||||
// will now be checked out decrypted.
|
// will now be checked out decrypted.
|
||||||
if (system("git reset --hard") != 0) {
|
// If HEAD doesn't exist (perhaps because this repo doesn't have any files yet)
|
||||||
|
// just skip the reset.
|
||||||
|
if (system("! git show-ref HEAD > /dev/null || git reset --hard HEAD") != 0) {
|
||||||
std::clog << "git reset --hard failed\n";
|
std::clog << "git reset --hard failed\n";
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user