Teach Git to respect skip-worktree bit (reading part)
[gitweb.git] / builtin-commit.c
index 88c51bdd3ae996673fa8abaa97a3da98396f5f3e..a0b1fd35cbacafd5afb79d3aa7a0e38e28960e8f 100644 (file)
@@ -180,6 +180,11 @@ static void add_remove_files(struct string_list *list)
        for (i = 0; i < list->nr; i++) {
                struct stat st;
                struct string_list_item *p = &(list->items[i]);
+               int pos = index_name_pos(&the_index, p->string, strlen(p->string));
+               struct cache_entry *ce = pos < 0 ? NULL : active_cache[pos];
+
+               if (ce && ce_skip_worktree(ce))
+                       continue;
 
                if (!lstat(p->string, &st)) {
                        if (add_to_cache(p->string, &st, 0))
@@ -434,7 +439,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
                if (isatty(0))
                        fprintf(stderr, "(reading log message from standard input)\n");
                if (strbuf_read(&sb, 0, 0) < 0)
-                       die("could not read log from standard input");
+                       die_errno("could not read log from standard input");
                hook_arg1 = "message";
        } else if (logfile) {
                if (strbuf_read_file(&sb, logfile, 0) < 0)
@@ -964,8 +969,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        /* Finally, get the commit message */
        strbuf_reset(&sb);
        if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+               int saved_errno = errno;
                rollback_index_files();
-               die("could not read commit message");
+               die("could not read commit message: %s", strerror(saved_errno));
        }
 
        /* Truncate the message just before the diff, if any. */