add: error appropriately on repository with no commits
[gitweb.git] / builtin / add.c
index db2dfa43502d0059219189f01731e143982345ab..dd18e5c9b67038307401e8d33970d5c424c03cb7 100644 (file)
@@ -374,11 +374,12 @@ static int add_files(struct dir_struct *dir, int flags)
        }
 
        for (i = 0; i < dir->nr; i++) {
-               check_embedded_repo(dir->entries[i]->name);
                if (add_file_to_index(&the_index, dir->entries[i]->name, flags)) {
                        if (!ignore_add_errors)
                                die(_("adding files failed"));
                        exit_status = 1;
+               } else {
+                       check_embedded_repo(dir->entries[i]->name);
                }
        }
        return exit_status;