git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Use of field flags in struct object
@ 2010-08-16  8:21 Nguyen Thai Ngoc Duy
  2010-08-25 18:55 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-08-16  8:21 UTC (permalink / raw)
  To: Git Mailing List

Hi,

The "flags" field in struct object (object.h) is used in a lot of
places. The thing is, the bit definition of this field is distributed
across files (16 according to my "object.flags |=" grep). This makes
it quite easy for one function to misunderstand a bit set by another
function, for a different purpose. For instance, in upload-pack.c,
there is a comment:

/* bits #0..7 in revision.h, #8..10 in commit.c */

which is no longer true as commit.c has moved on and used another set
of bits (16..19). Luckily, commit.c seems to clean its flags. But
there's a chance we will get bit definition overlap again.

Should all of those bit definitions be gathered in one place instead?
-- 
Duy

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Use of field flags in struct object
  2010-08-16  8:21 Use of field flags in struct object Nguyen Thai Ngoc Duy
@ 2010-08-25 18:55 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2010-08-25 18:55 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Git Mailing List

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:

> The "flags" field in struct object (object.h) is used in a lot of
> places. The thing is, the bit definition of this field is distributed
> across files (16 according to my "object.flags |=" grep). This makes
> it quite easy for one function to misunderstand a bit set by another
> function, for a different purpose. For instance, in upload-pack.c,
> there is a comment:
>
> /* bits #0..7 in revision.h, #8..10 in commit.c */
>
> which is no longer true as commit.c has moved on and used another set
> of bits (16..19). Luckily, commit.c seems to clean its flags. But
> there's a chance we will get bit definition overlap again.
>
> Should all of those bit definitions be gathered in one place instead?

In the medium term, probably yes.  In longer term, we would probably need
to rethink how these flag bits are managed.  Some users of these bits
might want to be migrated to the decorate API, for example.  It may also
be a possible improvement to move some bits that are only relevant to
commit objects (e.g.  left-right traversal, treesame, boundary) to struct
commit and additionally widen the bitfields there.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-25 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-16  8:21 Use of field flags in struct object Nguyen Thai Ngoc Duy
2010-08-25 18:55 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).