]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-commit.c
gitignore(5): Allow "foo/" in ignore list to match directory "foo"
[git.git] / builtin-commit.c
index 49541c0583803e4a5ec1503c02d30147933a7a36..c787bed696591f58d1336a701e57414c9d5c8cbf 100644 (file)
@@ -122,19 +122,23 @@ static void rollback_index_files(void)
        }
 }
 
-static void commit_index_files(void)
+static int commit_index_files(void)
 {
+       int err = 0;
+
        switch (commit_style) {
        case COMMIT_AS_IS:
                break; /* nothing to do */
        case COMMIT_NORMAL:
-               commit_lock_file(&index_lock);
+               err = commit_lock_file(&index_lock);
                break;
        case COMMIT_PARTIAL:
-               commit_lock_file(&index_lock);
+               err = commit_lock_file(&index_lock);
                rollback_lock_file(&false_lock);
                break;
        }
+
+       return err;
 }
 
 /*
@@ -237,7 +241,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
                int fd = hold_locked_index(&index_lock, 1);
                add_files_to_cache(0, also ? prefix : NULL, pathspec);
                refresh_cache(REFRESH_QUIET);
-               if (write_cache(fd, active_cache, active_nr))
+               if (write_cache(fd, active_cache, active_nr) ||
+                   close_lock_file(&index_lock))
                        die("unable to write new_index file");
                commit_style = COMMIT_NORMAL;
                return index_lock.filename;
@@ -298,7 +303,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
        fd = hold_locked_index(&index_lock, 1);
        add_remove_files(&partial);
        refresh_cache(REFRESH_QUIET);
-       if (write_cache(fd, active_cache, active_nr))
+       if (write_cache(fd, active_cache, active_nr) ||
+           close_lock_file(&index_lock))
                die("unable to write new_index file");
 
        fd = hold_lock_file_for_update(&false_lock,
@@ -308,7 +314,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
        add_remove_files(&partial);
        refresh_cache(REFRESH_QUIET);
 
-       if (write_cache(fd, active_cache, active_nr))
+       if (write_cache(fd, active_cache, active_nr) ||
+           close_lock_file(&false_lock))
                die("unable to write temporary index file");
        return false_lock.filename;
 }
@@ -594,7 +601,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
                if (get_sha1(use_message, sha1))
                        die("could not lookup commit %s", use_message);
-               commit = lookup_commit(sha1);
+               commit = lookup_commit_reference(sha1);
                if (!commit || parse_commit(commit))
                        die("could not parse commit %s", use_message);
 
@@ -923,7 +930,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        unlink(git_path("MERGE_HEAD"));
        unlink(git_path("MERGE_MSG"));
 
-       commit_index_files();
+       if (commit_index_files())
+               die ("Repository has been updated, but unable to write\n"
+                    "new_index file. Check that disk is not full or quota is\n"
+                    "not exceeded, and then \"git reset HEAD\" to recover.");
 
        rerere();
        run_hook(get_index_file(), "post-commit", NULL);