git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Patryk Obara <dreamer.tan@gmail.com>
Date
Mar 16, 2020, 12:31 UTC
Message-ID
<938146aa-e095-66fb-da0b-10e8796eaa12@gmail.com>
In-Reply-To
<xmqq1rpsako1.fsf@gitster.c.googlers.com>
On 16/03/2020 07:17, Junio C Hamano wrote:
Show 21 quoted lines
> Matheus Tavares <matheus.bernardino@usp.br> 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.

I think I stopped myself from more renames in that patch series, because the number of touched lines across various functions started to grow too fast and I was already stepping on brian's toes when touching oid conversions.

Show 9 quoted lines
> 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.

The evolution of this name seems to be an artefact of refactorization process, and not really a design decision:

info_exclude_sha1 (unsigned char[20]) changed to: ss_info_exclude (struct sha1_stat) changed to: ss_info_exclude (struct oid_stat)

There are some comments in dir.h still referring to info_exclude_sha1.

Therefore removing the prefix altogether (and fixing outdated comment!) would be very welcome.

On the other hand, naming them sss_info_exclude or sos_info_exclude would be quite funny, although I don't find hilarity to be a desirable quality for a naming convention ;)

-- 
| ← Ceci n'est pas une pipe
Patryk Obara
Previous: Junio C HamanoNext: Matheus Tavares Bernardino
Message 5 of 13 in “dir: update outdated fields and comments about oid_stat”
  1. 0/2 dir: update outdated fields and comments about oid_statMatheus Tavares, Mar 16, 2020
  2. 1/2 dir: fix outdated comment on add_patterns()Matheus Tavares, Mar 16, 2020
  3. 2/2 dir: improve naming of oid_stat fields in two structsMatheus Tavares, Mar 16, 2020
  4. Junio C HamanoMar 16, 2020
  5. Patryk ObaraMar 16, 2020
  6. Matheus Tavares BernardinoMar 16, 2020
  7. Junio C HamanoMar 16, 2020
  8. Junio C HamanoMar 16, 2020
  9. Jeff KingMar 16, 2020
  10. 0/3 dir: update outdated field names and comments about oid_statMatheus Tavares, Mar 17, 2020
  11. 1/3 dir: fix outdated comment on add_patterns()Matheus Tavares, Mar 17, 2020
  12. 2/3 dir: improve naming of oid_stat fields in two structsMatheus Tavares, Mar 17, 2020
  13. 3/3 dir: update outdated comments about untracked cacheMatheus Tavares, Mar 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.