From de694d232f1a1b1fe2ca4c7549242d7ef96cf759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 16 Jan 2012 09:36:47 +0700 Subject: commit, write-tree: allow to ignore CE_INTENT_TO_ADD while writing trees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin/commit.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'builtin/commit.c') 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) -- cgit v1.2.1