X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fcommit.c;h=66fdd2202495b2893c79b4f92b0fc2e715f5b7bb;hb=3988da063611de7391f794791a4622caf47c0708;hp=3d99cf91587593ecce56a603ca064888cdd60988;hpb=bcdfb20ae94138eac863b4c40263dc10f29917e5;p=git.git diff --git a/builtin/commit.c b/builtin/commit.c index 3d99cf915..66fdd2202 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -25,6 +25,7 @@ #include "rerere.h" #include "unpack-trees.h" #include "quote.h" +#include "submodule.h" static const char * const builtin_commit_usage[] = { "git commit [options] [--] ...", @@ -72,7 +73,7 @@ static char *author_name, *author_email, *author_date; static int all, edit_flag, also, interactive, only, amend, signoff; static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int no_post_rewrite, allow_empty_message; -static char *untracked_files_arg, *force_date; +static char *untracked_files_arg, *force_date, *ignore_submodule_arg; /* * The default commit message cleanup mode will remove the lines * beginning with # (shell comments) and leading and trailing @@ -147,7 +148,7 @@ static struct option builtin_commit_options[] = { "terminate entries with NUL"), OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"), OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"), - { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, + { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, /* end commit contents options */ { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL, @@ -219,7 +220,7 @@ static int list_paths(struct string_list *list, const char *with_tree, continue; if (!match_pathspec(pattern, ce->name, ce_namelen(ce), 0, m)) continue; - item = string_list_insert(ce->name, list); + item = string_list_insert(list, ce->name); if (ce_skip_worktree(ce)) item->util = item; /* better a valid pointer than a fake one */ } @@ -343,9 +344,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int if (!pathspec || !*pathspec) { fd = hold_locked_index(&index_lock, 1); refresh_cache_or_die(refresh_flags); - if (write_cache(fd, active_cache, active_nr) || - commit_locked_index(&index_lock)) - die("unable to write new_index file"); + if (active_cache_changed) { + if (write_cache(fd, active_cache, active_nr) || + commit_locked_index(&index_lock)) + die("unable to write new_index file"); + } else { + rollback_lock_file(&index_lock); + } commit_style = COMMIT_AS_IS; return get_index_file(); } @@ -1059,6 +1064,9 @@ int cmd_status(int argc, const char **argv, const char *prefix) PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, OPT_BOOLEAN(0, "ignored", &show_ignored_in_status, "show ignored files"), + { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, "when", + "ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)", + PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, OPT_END(), }; @@ -1066,6 +1074,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) status_format = STATUS_FORMAT_PORCELAIN; wt_status_prepare(&s); + gitmodules_config(); git_config(git_status_config, &s); in_merge = file_exists(git_path("MERGE_HEAD")); argc = parse_options(argc, argv, prefix, @@ -1082,13 +1091,16 @@ int cmd_status(int argc, const char **argv, const char *prefix) fd = hold_locked_index(&index_lock, 0); if (0 <= fd) { - if (!write_cache(fd, active_cache, active_nr)) + if (active_cache_changed && + !write_cache(fd, active_cache, active_nr)) commit_locked_index(&index_lock); - rollback_lock_file(&index_lock); + else + rollback_lock_file(&index_lock); } s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; s.in_merge = in_merge; + s.ignore_submodule_arg = ignore_submodule_arg; wt_status_collect(&s); if (s.relative_paths) @@ -1107,6 +1119,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) break; case STATUS_FORMAT_LONG: s.verbose = verbose; + s.ignore_submodule_arg = ignore_submodule_arg; wt_status_print(&s); break; } @@ -1152,7 +1165,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1) init_revisions(&rev, prefix); setup_revisions(0, NULL, &rev, NULL); - rev.abbrev = 0; rev.diff = 1; rev.diffopt.output_format = DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY;