git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH v4 00/19] Sparse checkout
Date: Fri, 21 Aug 2009 16:15:28 +0700	[thread overview]
Message-ID: <fcaeb9bf0908210215t5f694e3fp20c34e9c327f515b@mail.gmail.com> (raw)
In-Reply-To: <7vprapip1v.fsf@alter.siamese.dyndns.org>

2009/8/21 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> The recent assume-unchanged "breakage" that lets Git overwrite
>> assume-unchanged files worried me. I sat back, checked and wrote tests
>
> Yeah, it worries me, too.  Does the fix to make sure the sparse stuff
> won't be broken apply equally to assume-unchanged?  Does the series have
> such fixes to assume-unchanged bit as well?

This series does not fix assume-unchanged bit. I'd like to focus on
skip-worktree bit now. I still need to write a few more tests for
git-apply, git-checkout... but I think they are safe. It's up to you
to see if changes apply to assume-unchanged bit, in patches 4/19 and
5/19. I don't know if I understand assume-unchanged semantics
correctly anymore :-)

Anyway I think we could put a big fat warning above ce_uptodate()
macro definition, saying that this bit/macro could be faked by
assume-unchanged or skip-worktree bit, so don't rely on that macro
when it comes to writing (at least for skip-worktree part).

Hmm.. _or_ we could make it clear whether it is truly uptodate, or
faked uptodate. Some code path will be updated to only trust "truly
uptodate" bit, which is clearer and easier to grasp than messy logics
like "if (ce_uptodate(ce) && !ce_skip_worktree(ce))". Something like
this as a starting point (for demonstration only, I don't think it
compiles)

diff --git a/cache.h b/cache.h
index a401daf..05fb746 100644
--- a/cache.h
+++ b/cache.h
@@ -179,6 +179,7 @@ struct cache_entry {

 /* Only remove in work directory, not index */
 #define CE_WT_REMOVE (0x400000)
+#define CE_ASSUME_UPTODATE  (0x800000)

 /*
  * Extended on-disk flags
@@ -236,9 +237,11 @@ static inline size_t ce_namelen(const struct
cache_entry *ce)
 			    ondisk_cache_entry_extended_size(ce_namelen(ce)) : \
 			    ondisk_cache_entry_size(ce_namelen(ce)))
 #define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
-#define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
+#define ce_truely_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
+#define ce_uptodate(ce) ((ce)->ce_flags & (CE_UPTODATE | CE_ASSUME_UPTODATE))
 #define ce_skip_worktree(ce) ((ce)->ce_flags & CE_SKIP_WORKTREE)
 #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
+#define ce_mark_assume_uptodate(ce) ((ce)->ce_flags |= CE_ASSUME_UPTODATE)

 #define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
 static inline unsigned int create_ce_mode(unsigned int mode)
diff --git a/read-cache.c b/read-cache.c
index 5ee7d9d..c022955 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1005,7 +1005,7 @@ static struct cache_entry
*refresh_cache_ent(struct index_state *istate,
 		return ce;

 	if (!ignore_valid && ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce))) {
-		ce_mark_uptodate(ce);
+		ce_mark_assume_uptodate(ce);
 		return ce;
 	}

Still thinking of it. Seems like a good change...

> By the way, I think the first patch in the earlier series, 540e694
> (Prevent diff machinery from examining assume-unchanged entries on
> worktree, 2009-08-11), is a good change regardless of the sparse
> implementation, and I'm inclined to say that we should merge that part
> (and I suspect there will be similar fixes to really ignore differences to
> CE_VALID entries) first and then queue this new series on top.

I have no problem with that.
-- 
Duy

      reply	other threads:[~2009-08-21  9:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 13:46 [RFC PATCH v4 00/19] Sparse checkout Nguyễn Thái Ngọc Duy
2009-08-20 13:46 ` [RFC PATCH v4 01/19] update-index: refactor mark_valid() in preparation for new options Nguyễn Thái Ngọc Duy
2009-08-20 13:46   ` [RFC PATCH v4 02/19] Add test-index-version Nguyễn Thái Ngọc Duy
2009-08-20 13:46     ` [RFC PATCH v4 03/19] Introduce "skip-worktree" bit in index, teach Git to get/set this bit Nguyễn Thái Ngọc Duy
2009-08-20 13:46       ` [RFC PATCH v4 04/19] Teach Git to respect skip-worktree bit (reading part) Nguyễn Thái Ngọc Duy
2009-08-20 13:46         ` [RFC PATCH v4 05/19] Teach Git to respect skip-worktree bit (writing part) Nguyễn Thái Ngọc Duy
2009-08-20 13:47           ` [RFC PATCH v4 06/19] Avoid writing to buffer in add_excludes_from_file_1() Nguyễn Thái Ngọc Duy
2009-08-20 13:47             ` [RFC PATCH v4 07/19] Read .gitignore from index if it is skip-worktree Nguyễn Thái Ngọc Duy
2009-08-20 13:47               ` [RFC PATCH v4 08/19] unpack-trees(): carry skip-worktree bit over in merged_entry() Nguyễn Thái Ngọc Duy
2009-08-20 13:47                 ` [RFC PATCH v4 09/19] excluded_1(): support exclude files in index Nguyễn Thái Ngọc Duy
2009-08-20 13:47                   ` [RFC PATCH v4 10/19] dir.c: export excluded_1() and add_excludes_from_file_1() Nguyễn Thái Ngọc Duy
2009-08-20 13:47                     ` [RFC PATCH v4 11/19] Introduce "sparse checkout" Nguyễn Thái Ngọc Duy
2009-08-20 13:47                       ` [RFC PATCH v4 12/19] unpack-trees(): add CE_WT_REMOVE to remove on worktree alone Nguyễn Thái Ngọc Duy
2009-08-20 13:47                         ` [RFC PATCH v4 13/19] unpack-trees.c: generalize verify_* functions Nguyễn Thái Ngọc Duy
2009-08-20 13:47                           ` [RFC PATCH v4 14/19] unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout Nguyễn Thái Ngọc Duy
2009-08-20 13:47                             ` [RFC PATCH v4 15/19] unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index Nguyễn Thái Ngọc Duy
2009-08-20 13:47                               ` [RFC PATCH v4 16/19] unpack-trees(): ignore worktree check outside checkout area Nguyễn Thái Ngọc Duy
2009-08-20 13:47                                 ` [RFC PATCH v4 17/19] read-tree: add --no-sparse-checkout to disable sparse checkout support Nguyễn Thái Ngọc Duy
2009-08-20 13:47                                   ` [RFC PATCH v4 18/19] Add tests for sparse checkout Nguyễn Thái Ngọc Duy
2009-08-20 13:47                                     ` [RFC PATCH v4 19/19] sparse checkout: inhibit empty worktree Nguyễn Thái Ngọc Duy
2009-08-21  9:19         ` [RFC PATCH v4 04/19] Teach Git to respect skip-worktree bit (reading part) Nguyen Thai Ngoc Duy
2009-08-21 17:32           ` Junio C Hamano
2009-08-22 11:56             ` Nguyen Thai Ngoc Duy
2009-08-20 15:21 ` [RFC PATCH v4 00/19] Sparse checkout Jakub Narebski
2009-08-20 15:31   ` Matthieu Moy
2009-08-21  7:50 ` Junio C Hamano
2009-08-21  9:15   ` Nguyen Thai Ngoc Duy [this message]

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=fcaeb9bf0908210215t5f694e3fp20c34e9c327f515b@mail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).