aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/cfg-create.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx
index 355690a..f3ca80d 100644
--- a/bpkg/cfg-create.cxx
+++ b/bpkg/cfg-create.cxx
@@ -118,9 +118,29 @@ namespace bpkg
// Create .bpkg/ and its subdirectories.
//
{
- mk (c / bpkg_dir);
+ dir_path d (c / bpkg_dir);
+
+ mk (d);
mk (c / certs_dir);
mk (c / repos_dir);
+
+ // Create the .gitignore file that ignores everything under .bpkg/
+ // effectively making git ignore it (this prevents people from
+ // accidentally adding this directory to a git repository).
+ //
+ path f (d / ".gitignore");
+ try
+ {
+ ofdstream os (f);
+ os << "# This directory should not be version-controlled." << '\n'
+ << "#" << '\n'
+ << "*" << '\n';
+ os.close ();
+ }
+ catch (const io_error& e)
+ {
+ fail << "unable to write to " << f << ": " << e;
+ }
}
// Initialize tmp directory.