summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 56cac48)
raw | patch | inline | side by side (parent: 56cac48)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Mon, 14 Dec 2009 11:43:59 +0000 (18:43 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 14 Dec 2009 22:05:34 +0000 (14:05 -0800) |
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>
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>
builtin-commit.c | patch | blob | history | |
t/t7011-skip-worktree-reading.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index a0b1fd35cbacafd5afb79d3aa7a0e38e28960e8f..9d596903bfa2118e1385ebce9625bc14a63d53e7 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
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);
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)) {
index e996928de2b7f8f685f537e38e1c1b500ef223a8..bb4066f76762520b98caeba1cddaf442d80a4bf2 100755 (executable)
git rm 1
'
-test_expect_failure 'commit on skip-worktree absent entries' '
+test_expect_success 'commit on skip-worktree absent entries' '
git reset &&
setup_absent &&
test_must_fail git commit -m null 1
'
-test_expect_failure 'commit on skip-worktree dirty entries' '
+test_expect_success 'commit on skip-worktree dirty entries' '
git reset &&
setup_dirty &&
test_must_fail git commit -m null 1