about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--082persist.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/082persist.cc b/082persist.cc
index 3f9850fe..2c798cfb 100644
--- a/082persist.cc
+++ b/082persist.cc
@@ -42,9 +42,19 @@ case SAVE: {
   ofstream fout("lesson/recipe.mu");
   fout << contents;
   fout.close();
+  if (!exists("lesson/.git")) break;
   // bug in git: git diff -q messes up --exit-code
   int status = system("cd lesson; git diff --exit-code >/dev/null || git commit -a -m . >/dev/null");
   if (status != 0)
     raise << "error in commit: contents " << contents << '\n';
   break;
 }
+
+:(code)
+bool exists(const string& filename) {
+  struct stat dummy;
+  return 0 == stat(filename.c_str(), &dummy);
+}
+
+:(before "End Includes")
+#include<sys/stat.h>
ref='#n115'>115 116 117 118