Re: [PATCH 2/6] read-cache: new extension to mark what file is watched
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jan 13, 2014, 17:02 UTC
- Message-ID
- <20140113170222.GA18964@google.com>
- In-Reply-To
- <1389524622-6702-3-git-send-email-pclouds@gmail.com>
Hi,
Nguyễn Thái Ngọc Duy wrote:
Show 7 quoted lines
> If an entry is "watched", git lets an external program decide if the > entry is modified or not. It's more like --assume-unchanged, but > designed to be controlled by machine. > > We are running out of on-disk ce_flags, so instead of extending > on-disk entry format again, "watched" flags are in-core only and > stored as extension instead.
Makes sense.
Care to add a brief description of the on-disk format for Documetnation/technical/index-format.txt as well?
[...]
Show 7 quoted lines
> --- a/cache.h
> +++ b/cache.h
> @@ -168,6 +168,7 @@ struct cache_entry {
>
> /* used to temporarily mark paths matched by pathspecs */
> #define CE_MATCHED (1 << 26)
> +#define CE_WATCHED (1 << 27)Nit: I'd add a blank line before the definition of CE_WATCHED to make it clear that the comment doesn't apply to it.
Maybe it belongs with one of the groups before (e.g., UNPACKED + NEW_SKIP_WORKTREE). I dunno.
> --- a/read-cache.c > +++ b/read-cache.c
[...]
Show 16 quoted lines
> @@ -1289,6 +1290,19 @@ static int verify_hdr(struct cache_header *hdr,
> return 0;
> }
>
> +static void read_watch_extension(struct index_state *istate, uint8_t *data,
> + unsigned long sz)
> +{
> + int i;
> + if ((istate->cache_nr + 7) / 8 != sz) {
> + error("invalid 'WATC' extension");
> + return;
> + }
> + for (i = 0; i < istate->cache_nr; i++)
> + if (data[i / 8] & (1 << (i % 8)))
> + istate->cache[i]->ce_flags |= CE_WATCHED;
> +}So the WATC section has one bit per index entry, encoding whether that entry is WATCHED. Makes sense.
Do I understand correctly that this patch just takes care of the bookkeeping for the CE_WATCHED bit and the actual semantics will come in a later patch?
Thanks, Jonathan