There is nothing much to do when the index is committed as-is. But when partial commit is used, the index will be reset to HEAD. This leads to loss of skip-worktree bits in the original index. Those bits are kept (for committed paths only) so git-commit will know which paths to ignore later on. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin-commit.c | 11 +++++++++-- t/t7011-skip-worktree-reading.sh | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index 4bcce06..9fe5c25 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -152,7 +152,7 @@ static int commit_index_files(void) static int list_paths(struct string_list *list, const char *with_tree, const char *prefix, const char **pattern) { - int i; + static int i; char *m; for (i = 0; pattern[i]; i++) @@ -164,11 +164,15 @@ static int list_paths(struct string_list *list, const char *with_tree, for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; + struct string_list_item *item; + if (ce->ce_flags & CE_UPDATE) continue; if (!match_pathspec(pattern, ce->name, ce_namelen(ce), 0, m)) continue; - string_list_insert(ce->name, list); + item = string_list_insert(ce->name, list); + if (ce_skip_worktree(ce)) + item->util = &i; /* better a valid pointer than a fake one */ } return report_path_error(m, pattern, prefix ? strlen(prefix) : 0); @@ -181,6 +185,9 @@ static void add_remove_files(struct string_list *list) struct stat st; struct string_list_item *p = &(list->items[i]); + if (p->util) + continue; + if (!lstat(p->string, &st)) { if (add_to_cache(p->string, &st, 0)) die("updating files failed"); diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh index 2ec677a..5cf2cb8 100755 --- a/t/t7011-skip-worktree-reading.sh +++ b/t/t7011-skip-worktree-reading.sh @@ -143,4 +143,16 @@ test_expect_success 'diff-files does not examine skip-worktree dirty entries' ' test -z "$(git diff-files -- one)" ' +test_expect_success 'commit on skip-worktree absent entries' ' + git reset && + setup_absent && + test_must_fail git commit -m null 1 +' + +test_expect_success 'commit on skip-worktree dirty entries' ' + git reset && + setup_dirty && + test_must_fail git commit -m null 1 +' + test_done -- 1.6.5.2.216.g9c1ec -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html