Code

Merge branch 'js/config-cb'
[git.git] / builtin-commit.c
index a113eb0272438e60ca0af6dff441b9279cd2d133..07872c8ea71064c1bcf5813dd66b4a7e5feb9bec 100644 (file)
@@ -102,7 +102,7 @@ static struct option builtin_commit_options[] = {
        OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
        OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
        OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
-       OPT_BOOLEAN(0, "untracked-files", &untracked_files, "show all untracked files"),
+       OPT_BOOLEAN('u', "untracked-files", &untracked_files, "show all untracked files"),
        OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
        OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
 
@@ -176,10 +176,13 @@ static void add_remove_files(struct path_list *list)
 {
        int i;
        for (i = 0; i < list->nr; i++) {
+               struct stat st;
                struct path_list_item *p = &(list->items[i]);
-               if (file_exists(p->path))
-                       add_file_to_cache(p->path, 0);
-               else
+
+               if (!lstat(p->path, &st)) {
+                       if (add_to_cache(p->path, &st, 0))
+                               die("updating files failed");
+               } else
                        remove_file_from_cache(p->path);
        }
 }
@@ -244,7 +247,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
         */
        if (all || (also && pathspec && *pathspec)) {
                int fd = hold_locked_index(&index_lock, 1);
-               add_files_to_cache(0, also ? prefix : NULL, pathspec);
+               add_files_to_cache(also ? prefix : NULL, pathspec, 0);
                refresh_cache(REFRESH_QUIET);
                if (write_cache(fd, active_cache, active_nr) ||
                    close_lock_file(&index_lock))
@@ -803,7 +806,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        const char *index_file;
        int commitable;
 
-       git_config(git_status_config);
+       git_config(git_status_config, NULL);
 
        if (wt_status_use_color == -1)
                wt_status_use_color = git_use_color_default;
@@ -857,7 +860,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
        }
 }
 
-int git_commit_config(const char *k, const char *v)
+int git_commit_config(const char *k, const char *v, void *cb)
 {
        if (!strcmp(k, "commit.template")) {
                if (!v)
@@ -866,7 +869,7 @@ int git_commit_config(const char *k, const char *v)
                return 0;
        }
 
-       return git_status_config(k, v);
+       return git_status_config(k, v, cb);
 }
 
 static const char commit_utf8_warn[] =
@@ -894,7 +897,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        unsigned char commit_sha1[20];
        struct ref_lock *ref_lock;
 
-       git_config(git_commit_config);
+       git_config(git_commit_config, NULL);
 
        argc = parse_and_validate_options(argc, argv, builtin_commit_usage);