]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/cvs.pm
Knock off a to-do item: "If the argument to cvs add smells like a
[ikiwiki.git] / IkiWiki / Plugin / cvs.pm
index 20b9f793ad3dc13a1444badaeda3ca7251342aa5..ccd9527cd799039618242742a19270557facfbb2 100644 (file)
@@ -219,14 +219,25 @@ sub rcs_add ($) {
        my $parent=IkiWiki::dirname($file);
        my @files_to_add = ($file);
 
+       eval q{use File::MimeInfo};
+       error($@) if $@;
+
        until ((length($parent) == 0) || cvs_is_controlling("$config{srcdir}/$parent")){
                push @files_to_add, $parent;
                $parent = IkiWiki::dirname($parent);
        }
 
        while ($file = pop @files_to_add) {
-               cvs_runcvs(['add', $file]) ||
-                       warn("cvs add $file failed\n");
+               if ((@files_to_add == 0) &&
+                       (File::MimeInfo::default $file ne 'text/plain')) {
+                       # it's a binary file, add specially
+                       cvs_runcvs(['add', '-kb', $file]) ||
+                               warn("cvs add $file failed\n");
+               } else {
+                       # directory or regular file
+                       cvs_runcvs(['add', $file]) ||
+                               warn("cvs add $file failed\n");
+               }
        }
 }