aboutsummaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-12-14 18:43:59 +0700
committerJunio C Hamano <gitster@pobox.com>2009-12-14 14:05:34 -0800
commit7fce6e3c9a3cf652099ee5f0e52b59c407692044 (patch)
treefe2e169e890c6868242b277f6d63afbc145e8995 /builtin-commit.c
parent56cac48c3550de88d71b3944576d44337261d71b (diff)
downloadgit-7fce6e3c9a3cf652099ee5f0e52b59c407692044.tar.gz
git-7fce6e3c9a3cf652099ee5f0e52b59c407692044.tar.xz
commit: correctly respect skip-worktree bit
Commit b4d1690 (Teach Git to respect skip-worktree bit (reading part)) fails to make "git commit -- a b c" respect skip-worktree (i.e. not committing paths that are skip-worktree). This is because when the index is reset back to HEAD, all skip-worktree information is gone. This patch saves skip-worktree information in the string list of committed paths, then reuse it later on to skip skip-worktree paths. 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.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index a0b1fd35c..9d596903b 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -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 = item; /* better a valid pointer than a fake one */
}
return report_path_error(m, pattern, prefix ? strlen(prefix) : 0);
@@ -180,10 +184,9 @@ static void add_remove_files(struct string_list *list)
for (i = 0; i < list->nr; i++) {
struct stat st;
struct string_list_item *p = &(list->items[i]);
- int pos = index_name_pos(&the_index, p->string, strlen(p->string));
- struct cache_entry *ce = pos < 0 ? NULL : active_cache[pos];
- if (ce && ce_skip_worktree(ce))
+ /* p->util is skip-worktree */
+ if (p->util)
continue;
if (!lstat(p->string, &st)) {