Re: [PATCH v4 2/8] block alloc: add lifecycle APIs for cache_entry structs
- From
Stefan Beller <sbeller@google.com>
- Date
- Jun 21, 2018, 21:14 UTC
- Message-ID
- <CAGZ79katH2Kk2NDDyZjYzC9fEKS6cDdHK1Cw2JLjjSfmYOPapw@mail.gmail.com>
- In-Reply-To
- <20180620201557.77155-3-jamill@microsoft.com>
Show 14 quoted lines
> --- a/cache.h > +++ b/cache.h > @@ -339,6 +339,29 @@ extern void remove_name_hash(struct index_state *istate, struct cache_entry *ce) > extern void free_name_hash(struct index_state *istate); > > > +/* Cache entry creation and cleanup */ > + > +/* > + * Create cache_entry intended for use in the specified index. Caller > + * is responsible for discarding the cache_entry with > + * `discard_cache_entry`. > + */ > +extern struct cache_entry *make_cache_entry(struct index_state *istate, unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
How much work is it to convert these to object_id while at it instead of char *sha1? (I think we really dislike introducing new sha1 based code; If it doesn't sound easy maybe we can have a static inline wrapper here that just converts oid to sha1 and then calls this function?)
Is it possible to line break these functions (c.f. refs.h which I think has one of the best styles in the git project. It has long parameter lists, but still manages to stay below a reasonable line length) ?
> +extern struct cache_entry *make_empty_cache_entry(struct index_state *istate, size_t name_len);
Show 13 quoted lines
> + > +/* > + * Create a cache_entry that is not intended to be added to an index. > + * Caller is responsible for discarding the cache_entry > + * with `discard_cache_entry`. > + */ > +extern struct cache_entry *make_transient_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage); > +extern struct cache_entry *make_empty_transient_cache_entry(size_t name_len); > + > +/* > + * Discard cache entry. > + */ > +void discard_cache_entry(struct cache_entry *ce);
Please be consistent in the use of the extern keyword and omit them at all times here and above.