]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/git.pm
git: Avoid adding files when committing, so as not to implicitly add files like recen...
[ikiwiki.git] / IkiWiki / Plugin / git.pm
index 39d88d002716326b8c1acdc2c2c54705da351d34..3db4af7291b0d11dcdf8bc89386b93133c963e10 100644 (file)
@@ -496,16 +496,16 @@ sub rcs_commit (@) {
                return $conflict if defined $conflict;
        }
 
-       rcs_add($params{file});
-       return rcs_commit_staged(
-               message => $params{message},
-               session => $params{session},
-       );
+       return rcs_commit_helper(@_);
 }
 
 sub rcs_commit_staged (@) {
        # Commits all staged changes. Changes can be staged using rcs_add,
        # rcs_remove, and rcs_rename.
+       return rcs_commit_helper(@_);
+}
+
+sub rcs_commit_helper (@) {
        my %params=@_;
        
        my %env=%ENV;
@@ -546,10 +546,12 @@ sub rcs_commit_staged (@) {
                        $params{message}.=".";
                }
        }
-       push @opts, '-q';
-       # git commit returns non-zero if file has not been really changed.
-       # so we should ignore its exit status (hence run_or_non).
-       if (run_or_non('git', 'commit', @opts, '-m', $params{message})) {
+       if (exists $params{file}) {
+               push @opts, '--', $params{file};
+       }
+       # git commit returns non-zero if nothing really changed.
+       # So we should ignore its exit status (hence run_or_non).
+       if (run_or_non('git', 'commit', '-m', $params{message}, '-q', @opts)) {
                if (length $config{gitorigin_branch}) {
                        run_or_cry('git', 'push', $config{gitorigin_branch});
                }