disallow directories with 'got add'; add a TODO item for them
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/TODO b/TODO
index cc9cceb..e957e0f 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,7 @@ lib:
- handle checkout of trees which contain submodules by identifying and
ignoring such tree entries; requires a .ini config parser (from isakmpd?)
- allow removing multiple paths at once for 'got rm'
+- allow adding directory paths with 'got add'
- recursive addition: got add -R
- recursive removal: got rm -R
diff --git a/lib/fileindex.c b/lib/fileindex.c
index a868d40..61562ca 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -18,6 +18,7 @@
#include <sys/tree.h>
#include <sys/stat.h>
+#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
@@ -60,8 +61,12 @@ got_fileindex_entry_update(struct got_fileindex_entry *entry,
if (lstat(ondisk_path, &sb) != 0) {
if ((entry->flags & GOT_FILEIDX_F_NO_FILE_ON_DISK) == 0)
return got_error_prefix_errno2("lstat", ondisk_path);
- } else
+ } else {
+ if (sb.st_mode & S_IFDIR)
+ return got_error_set_errno(EISDIR, ondisk_path);
entry->flags &= ~GOT_FILEIDX_F_NO_FILE_ON_DISK;
+ }
+
if ((entry->flags & GOT_FILEIDX_F_NO_FILE_ON_DISK) == 0) {
if (update_timestamps) {