Re: [PATCH/RFC v3 01/13] Move index v2 specific functions to their own file
- From
Thomas Gummerer <t.gummerer@gmail.com>
- Date
- Aug 8, 2012, 19:21 UTC
- Message-ID
- <20120808192041.GA25671@tommy-fedora.surfnet.iacbox>
- In-Reply-To
- <CACsJy8CY--Z_BfscRCG8+Om1Z8JsFgj0BkjNyMJnwsbmyGRLXQ@mail.gmail.com>
On 08/08, Nguyen Thai Ngoc Duy wrote:
Show 32 quoted lines
> On Wed, Aug 8, 2012 at 6:17 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:
> > Move index version 2 specific functions to their own file,
> > to prepare for the addition of a new index file format. With
> > the split into two files we have the non-index specific
> > functions in read-cache.c and the index-v2 specific functions
> > in read-cache-v2.c
>
> You still mix code changes and code move in one patch, but we can skip
> it for now.
>
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -267,6 +259,7 @@ struct index_state {
> > unsigned name_hash_initialized : 1,
> > initialized : 1;
> > struct hash_table name_hash;
> > + struct index_ops *ops;
> > };
>
> Do we really need to modify "ops" content? If not make it "const
> struct index_ops *ops;" which makes..
>
> > @@ -471,8 +464,8 @@ extern int index_name_is_other(const struct index_state *, const char *, int);
> > #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);
> > +extern int ie_match_stat(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
> > +extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
>
> ..this hunk go awayUnfortunately I think we need to modify it, because in some cases when ie_modified/ie_match_stat is called, index->ops is not set yet (happens when the index is empty and thus not read first). Therefore we have to set it in ce_match_stat_basic to have access to the format specific match_stat_basic.
We could also call match_stat_basic directly from the v[25]_ops struct, but I do not think that would be the cleaner solution, or is there any other way to do it, which I can't see?