Re: [PATCH 2/2] dir: improve naming of oid_stat fields in two structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 16, 2020 at 3:17 AM Junio C Hamano <gitster@xxxxxxxxx> wrote:
>
> Matheus Tavares <matheus.bernardino@xxxxxx> writes:
>
> > Note: I choosed to use "st_*", as naming, for simplicity, and to keep
> > the code lines small. But should we use a more verbose "oidst_*" format,
> > instead, to avoid confusions with "struct stat"?
> > ...
> > @@ -334,8 +334,8 @@ struct dir_struct {
> >
> >       /* Enable untracked file cache if set */
> >       struct untracked_cache *untracked;
> > -     struct oid_stat ss_info_exclude;
> > -     struct oid_stat ss_excludes_file;
> > +     struct oid_stat st_info_exclude;
> > +     struct oid_stat st_excludes_file;
> >       unsigned unmanaged_exclude_files;
> >  };
>
> I tend to agree with you that using prefix "st_" for anything other
> than "struct stat" proper would be confusing.  If "ss" used to stand
> for "sha1 stat", I would expect "oid stat" to abbreviate to "os", at
> least.

Right. I also thought about changing the names to "os_*". But since OS
is so commonly used for "Operating System", I wasn't sure whether that
could also be somehow confusing.

> I also am wondering if we can do without any prefix, i.e. just call
> them "info_exclude" and "excludes_file", because the field names are
> private to each struct and there is no strong reason to have a
> common prefix among fields in a single struct.  Rather, it is more
> important for the fields of the same type in a single struct to have
> distinct names so that the reader can easily tell them apart and the
> reason for their use is straight-forward to understand, and the two
> names without any prefix convey their distinction pretty well, I
> would think.

Yes, I guess removing the prefix wouldn't make the names less
descriptive. However, especially for "ss_excludes_file", I think using
just "excludes_file" might induce the reader to think that the field
refers to a "char *" holding a path. (We also have a "excludes_file"
global variable in environment.c which is used like that). What if we
renamed them to "oidst_info_exclude" and "oidst_excludes_file", would
that be too verbose?



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux