Allow empty folders to be added by putting a hidden file in each of them before committing

This commit is contained in:
Hylke Bons 2011-09-14 19:30:17 +02:00
parent ac3abe5b8c
commit d0244e0da6

View file

@ -165,6 +165,8 @@ namespace SparkleLib {
public override bool AnyDifferences {
get {
FillEmptyDirectories (LocalPath);
SparkleGit git = new SparkleGit (LocalPath, "status --porcelain");
git.Start ();
@ -509,6 +511,22 @@ namespace SparkleLib {
}
// Git doesn't track empty directories, so this method
// fills them all with a hidden empty file
private void FillEmptyDirectories (string path)
{
foreach (string child_path in Directory.GetDirectories (path)) {
if (path.EndsWith (".git") || path.EndsWith (".notes"))
continue;
FillEmptyDirectories (child_path);
}
if (Directory.GetFiles (path).Length == 0)
File.Create (Path.Combine (path, ".empty"));
}
// Creates a pretty commit message based on what has changed
private string FormatCommitMessage ()
{