diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2012-01-16 09:36:47 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-01-16 14:53:41 -0800 |
commit | de694d232f1a1b1fe2ca4c7549242d7ef96cf759 (patch) | |
tree | c1d87e533b08e495cfbf54e060ce0775d877ee6f /builtin/commit.c | |
parent | c010eb63079843f73b4906e2a5a048f5c4e88610 (diff) | |
download | git-nd/commit-ignore-i-t-a.tar.gz |
commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing treesnd/commit-ignore-i-t-a
Normally cache-tree will not produce trees from an index that has
CE_INTENT_TO_ADD entries. This is a safe measure to avoid
mis-interpreting user's intention regarding this flag.
There are situations however where users want to create trees/commits
regardless i-t-a entries. Allow such cases with commit.ignoreIntentToAdd
for git-commit and --ignore-intent-to-add for git-write-tree.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index bf42bb384d..097699e39e 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -86,6 +86,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff; static int edit_flag = -1; /* unspecified */ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int no_post_rewrite, allow_empty_message; +static int cache_tree_flags; static char *untracked_files_arg, *force_date, *ignore_submodule_arg; static char *sign_commit; @@ -400,7 +401,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, fd = hold_locked_index(&index_lock, 1); add_files_to_cache(also ? prefix : NULL, pathspec, 0); refresh_cache_or_die(refresh_flags); - update_main_cache_tree(WRITE_TREE_SILENT); + update_main_cache_tree(cache_tree_flags | WRITE_TREE_SILENT); if (write_cache(fd, active_cache, active_nr) || close_lock_file(&index_lock)) die(_("unable to write new_index file")); @@ -421,7 +422,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, fd = hold_locked_index(&index_lock, 1); refresh_cache_or_die(refresh_flags); if (active_cache_changed) { - update_main_cache_tree(WRITE_TREE_SILENT); + update_main_cache_tree(cache_tree_flags | WRITE_TREE_SILENT); if (write_cache(fd, active_cache, active_nr) || commit_locked_index(&index_lock)) die(_("unable to write new_index file")); @@ -870,7 +871,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, */ discard_cache(); read_cache_from(index_file); - if (update_main_cache_tree(0)) { + if (update_main_cache_tree(cache_tree_flags)) { error(_("Error building trees")); return 0; } @@ -1338,6 +1339,12 @@ static int git_commit_config(const char *k, const char *v, void *cb) include_status = git_config_bool(k, v); return 0; } + if (!strcmp(k, "commit.ignoreintenttoadd")) { + if (git_config_bool(k, v)) + cache_tree_flags |= WRITE_TREE_IGNORE_INTENT_TO_ADD; + else + cache_tree_flags &= ~WRITE_TREE_IGNORE_INTENT_TO_ADD; + } status = git_gpg_config(k, v, NULL); if (status) |