From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 04/23] update-index: ignore update request if it's skip-worktree
Date: Mon, 14 Dec 2009 17:30:47 +0700 [thread overview]
Message-ID: <1260786666-8405-5-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1260786666-8405-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-apply.c | 2 +-
cache.h | 2 ++
entry.c | 2 +-
read-cache.c | 17 ++++++++++++++---
unpack-trees.c | 6 +++---
5 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 39dc96a..7717a66 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2505,7 +2505,7 @@ static int verify_index_match(struct cache_entry *ce, struct stat *st)
return -1;
return 0;
}
- return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID);
+ return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
}
static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)
diff --git a/cache.h b/cache.h
index f266246..f040f24 100644
--- a/cache.h
+++ b/cache.h
@@ -462,6 +462,8 @@ extern int index_name_is_other(const struct index_state *, const char *, int);
#define CE_MATCH_IGNORE_VALID 01
/* do not check the contents but report dirty on racily-clean entries */
#define CE_MATCH_RACY_IS_DIRTY 02
+/* do stat comparison even if CE_SKIP_WORKTREE is true */
+#define CE_MATCH_IGNORE_SKIP_WORKTREE 04
extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
diff --git a/entry.c b/entry.c
index f276cf3..efee21f 100644
--- a/entry.c
+++ b/entry.c
@@ -202,7 +202,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
len += ce_namelen(ce);
if (!check_path(path, len, &st)) {
- unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID);
+ unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
if (!changed)
return 0;
if (!state->force) {
diff --git a/read-cache.c b/read-cache.c
index 4e3e272..b31861c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -259,12 +259,17 @@ int ie_match_stat(const struct index_state *istate,
{
unsigned int changed;
int ignore_valid = options & CE_MATCH_IGNORE_VALID;
+ int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE;
int assume_racy_is_modified = options & CE_MATCH_RACY_IS_DIRTY;
/*
* If it's marked as always valid in the index, it's
* valid whatever the checked-out copy says.
+ *
+ * skip-worktree has the same effect with higher precedence
*/
+ if (!ignore_skip_worktree && ce_skip_worktree(ce))
+ return 0;
if (!ignore_valid && (ce->ce_flags & CE_VALID))
return 0;
@@ -564,7 +569,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
int size, namelen, was_same;
mode_t st_mode = st->st_mode;
struct cache_entry *ce, *alias;
- unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
+ unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE|CE_MATCH_RACY_IS_DIRTY;
int verbose = flags & (ADD_CACHE_VERBOSE | ADD_CACHE_PRETEND);
int pretend = flags & ADD_CACHE_PRETEND;
int intent_only = flags & ADD_CACHE_INTENT;
@@ -1000,14 +1005,20 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
struct cache_entry *updated;
int changed, size;
int ignore_valid = options & CE_MATCH_IGNORE_VALID;
+ int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE;
if (ce_uptodate(ce))
return ce;
/*
- * CE_VALID means the user promised us that the change to
- * the work tree does not matter and told us not to worry.
+ * CE_VALID or CE_SKIP_WORKTREE means the user promised us
+ * that the change to the work tree does not matter and told
+ * us not to worry.
*/
+ if (!ignore_skip_worktree && ce_skip_worktree(ce)) {
+ ce_mark_uptodate(ce);
+ return ce;
+ }
if (!ignore_valid && (ce->ce_flags & CE_VALID)) {
ce_mark_uptodate(ce);
return ce;
diff --git a/unpack-trees.c b/unpack-trees.c
index 720f7a1..4870da9 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -454,7 +454,7 @@ static int verify_uptodate(struct cache_entry *ce,
return 0;
if (!lstat(ce->name, &st)) {
- unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID);
+ unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
if (!changed)
return 0;
/*
@@ -572,7 +572,7 @@ static int icase_exists(struct unpack_trees_options *o, struct cache_entry *dst,
struct cache_entry *src;
src = index_name_exists(o->src_index, dst->name, ce_namelen(dst), 1);
- return src && !ie_match_stat(o->src_index, src, st, CE_MATCH_IGNORE_VALID);
+ return src && !ie_match_stat(o->src_index, src, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
}
/*
@@ -1007,7 +1007,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
if (o->reset && !ce_uptodate(old)) {
struct stat st;
if (lstat(old->name, &st) ||
- ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID))
+ ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
update |= CE_UPDATE;
}
add_entry(o, old, update, 0);
--
1.6.5.2.216.g9c1ec
next prev parent reply other threads:[~2009-12-14 10:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 10:30 [PATCH 00/23] nd/sparse reroll Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 01/23] update-index: refactor mark_valid() in preparation for new options Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 02/23] Add test-index-version Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 03/23] Introduce "skip-worktree" bit in index, teach Git to get/set this bit Nguyễn Thái Ngọc Duy
2009-12-14 23:06 ` Greg Price
2009-12-15 3:51 ` Nguyen Thai Ngoc Duy
2009-12-15 7:20 ` Johannes Sixt
2009-12-15 8:05 ` Nguyen Thai Ngoc Duy
2009-12-14 10:30 ` Nguyễn Thái Ngọc Duy [this message]
2009-12-14 10:30 ` [PATCH 05/23] Teach ls-files and update-index to respect skip-worktree bit Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 06/23] Teach diff machinery " Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 07/23] Teach grep " Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 08/23] Teach commit " Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 09/23] Teach Git to respect skip-worktree bit (writing part) Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 10/23] Avoid writing to buffer in add_excludes_from_file_1() Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 11/23] Read .gitignore from index if it is skip-worktree Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 12/23] unpack-trees(): carry skip-worktree bit over in merged_entry() Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 13/23] excluded_1(): support exclude files in index Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 14/23] dir.c: export excluded_1() and add_excludes_from_file_1() Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 15/23] Introduce "sparse checkout" Nguyễn Thái Ngọc Duy
2009-12-14 10:30 ` [PATCH 16/23] unpack-trees(): add CE_WT_REMOVE to remove on worktree alone Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 17/23] unpack-trees.c: generalize verify_* functions Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 18/23] unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 19/23] unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 20/23] unpack-trees(): ignore worktree check outside checkout area Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 21/23] read-tree: add --no-sparse-checkout to disable sparse checkout support Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 22/23] Add tests for sparse checkout Nguyễn Thái Ngọc Duy
2009-12-14 10:31 ` [PATCH 23/23] sparse checkout: inhibit empty worktree Nguyễn Thái Ngọc Duy
2009-12-14 11:09 ` [PATCH 00/23] nd/sparse reroll Johannes Sixt
2009-12-14 11:11 ` Nguyen Thai Ngoc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1260786666-8405-5-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.