git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matheus Tavares <matheus.bernardino@usp.br>
To: git@vger.kernel.org
Cc: gitster@pobox.com, "René Scharfe" <l.s.r@web.de>,
	"Jeff King" <peff@peff.net>
Subject: [PATCH 2/2] dir: improve naming of oid_stat fields in two structs
Date: Mon, 16 Mar 2020 00:47:27 -0300	[thread overview]
Message-ID: <6fee28469e49d501e5184162bc820350f60cc3de.1584329834.git.matheus.bernardino@usp.br> (raw)
In-Reply-To: <cover.1584329834.git.matheus.bernardino@usp.br>

Both "struct untracked_cache" and "struct dir_struct" contain fields of
the type "struct oid_stat". The latter used to be called "sha1_stat"
before 4b33e60 ("dir: convert struct sha1_stat to use object_id",
2018-01-28). Although this struct was renamed, the previously
mentioned fields are still named in the format "ss_*", which refers to
the old "sha1_stat". Since this might be confusing, rename those fields
as "st_*", referring to "stat", instead.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---

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"?

 dir.c                                | 28 ++++++++++++++--------------
 dir.h                                |  8 ++++----
 t/helper/test-dump-untracked-cache.c |  4 ++--
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/dir.c b/dir.c
index ab2e5b8717..e678c8184c 100644
--- a/dir.c
+++ b/dir.c
@@ -2613,15 +2613,15 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
 
 	/* Validate $GIT_DIR/info/exclude and core.excludesfile */
 	root = dir->untracked->root;
-	if (!oideq(&dir->ss_info_exclude.oid,
-		   &dir->untracked->ss_info_exclude.oid)) {
+	if (!oideq(&dir->st_info_exclude.oid,
+		   &dir->untracked->st_info_exclude.oid)) {
 		invalidate_gitignore(dir->untracked, root);
-		dir->untracked->ss_info_exclude = dir->ss_info_exclude;
+		dir->untracked->st_info_exclude = dir->st_info_exclude;
 	}
-	if (!oideq(&dir->ss_excludes_file.oid,
-		   &dir->untracked->ss_excludes_file.oid)) {
+	if (!oideq(&dir->st_excludes_file.oid,
+		   &dir->untracked->st_excludes_file.oid)) {
 		invalidate_gitignore(dir->untracked, root);
-		dir->untracked->ss_excludes_file = dir->ss_excludes_file;
+		dir->untracked->st_excludes_file = dir->st_excludes_file;
 	}
 
 	/* Make sure this directory is not dropped out at saving phase */
@@ -2884,14 +2884,14 @@ void setup_standard_excludes(struct dir_struct *dir)
 		excludes_file = xdg_config_home("ignore");
 	if (excludes_file && !access_or_warn(excludes_file, R_OK, 0))
 		add_patterns_from_file_1(dir, excludes_file,
-					 dir->untracked ? &dir->ss_excludes_file : NULL);
+					 dir->untracked ? &dir->st_excludes_file : NULL);
 
 	/* per repository user preference */
 	if (startup_info->have_repository) {
 		const char *path = git_path_info_exclude();
 		if (!access_or_warn(path, R_OK, 0))
 			add_patterns_from_file_1(dir, path,
-						 dir->untracked ? &dir->ss_info_exclude : NULL);
+						 dir->untracked ? &dir->st_info_exclude : NULL);
 	}
 }
 
@@ -3037,8 +3037,8 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
 	const unsigned hashsz = the_hash_algo->rawsz;
 
 	ouc = xcalloc(1, sizeof(*ouc));
-	stat_data_to_disk(&ouc->info_exclude_stat, &untracked->ss_info_exclude.stat);
-	stat_data_to_disk(&ouc->excludes_file_stat, &untracked->ss_excludes_file.stat);
+	stat_data_to_disk(&ouc->info_exclude_stat, &untracked->st_info_exclude.stat);
+	stat_data_to_disk(&ouc->excludes_file_stat, &untracked->st_excludes_file.stat);
 	ouc->dir_flags = htonl(untracked->dir_flags);
 
 	varint_len = encode_varint(untracked->ident.len, varbuf);
@@ -3046,8 +3046,8 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
 	strbuf_addbuf(out, &untracked->ident);
 
 	strbuf_add(out, ouc, sizeof(*ouc));
-	strbuf_add(out, untracked->ss_info_exclude.oid.hash, hashsz);
-	strbuf_add(out, untracked->ss_excludes_file.oid.hash, hashsz);
+	strbuf_add(out, untracked->st_info_exclude.oid.hash, hashsz);
+	strbuf_add(out, untracked->st_excludes_file.oid.hash, hashsz);
 	strbuf_add(out, untracked->exclude_per_dir, strlen(untracked->exclude_per_dir) + 1);
 	FREE_AND_NULL(ouc);
 
@@ -3250,10 +3250,10 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
 	uc = xcalloc(1, sizeof(*uc));
 	strbuf_init(&uc->ident, ident_len);
 	strbuf_add(&uc->ident, ident, ident_len);
-	load_oid_stat(&uc->ss_info_exclude,
+	load_oid_stat(&uc->st_info_exclude,
 		      next + ouc_offset(info_exclude_stat),
 		      next + offset);
-	load_oid_stat(&uc->ss_excludes_file,
+	load_oid_stat(&uc->st_excludes_file,
 		      next + ouc_offset(excludes_file_stat),
 		      next + offset + hashsz);
 	uc->dir_flags = get_be32(next + ouc_offset(dir_flags));
diff --git a/dir.h b/dir.h
index 5855c065a6..4d30816271 100644
--- a/dir.h
+++ b/dir.h
@@ -186,8 +186,8 @@ struct untracked_cache_dir {
 };
 
 struct untracked_cache {
-	struct oid_stat ss_info_exclude;
-	struct oid_stat ss_excludes_file;
+	struct oid_stat st_info_exclude;
+	struct oid_stat st_excludes_file;
 	const char *exclude_per_dir;
 	struct strbuf ident;
 	/*
@@ -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;
 };
 
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index cf0f2c7228..71a47e974b 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -56,8 +56,8 @@ int cmd__dump_untracked_cache(int ac, const char **av)
 		printf("no untracked cache\n");
 		return 0;
 	}
-	printf("info/exclude %s\n", oid_to_hex(&uc->ss_info_exclude.oid));
-	printf("core.excludesfile %s\n", oid_to_hex(&uc->ss_excludes_file.oid));
+	printf("info/exclude %s\n", oid_to_hex(&uc->st_info_exclude.oid));
+	printf("core.excludesfile %s\n", oid_to_hex(&uc->st_excludes_file.oid));
 	printf("exclude_per_dir %s\n", uc->exclude_per_dir);
 	printf("flags %08x\n", uc->dir_flags);
 	if (uc->root)
-- 
2.25.0


  parent reply	other threads:[~2020-03-16  3:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16  3:47 [PATCH 0/2] dir: update outdated fields and comments about oid_stat Matheus Tavares
2020-03-16  3:47 ` [PATCH 1/2] dir: fix outdated comment on add_patterns() Matheus Tavares
2020-03-16  3:47 ` Matheus Tavares [this message]
2020-03-16  6:17   ` [PATCH 2/2] dir: improve naming of oid_stat fields in two structs Junio C Hamano
2020-03-16 12:31     ` Patryk Obara
2020-03-16 17:22     ` Matheus Tavares Bernardino
2020-03-16 18:31       ` Junio C Hamano
2020-03-16 18:35         ` Junio C Hamano
2020-03-16 19:20           ` Jeff King
2020-03-17 18:57 ` [PATCH v2 0/3] dir: update outdated field names and comments about oid_stat Matheus Tavares
2020-03-17 18:57   ` [PATCH v2 1/3] dir: fix outdated comment on add_patterns() Matheus Tavares
2020-03-17 18:57   ` [PATCH v2 2/3] dir: improve naming of oid_stat fields in two structs Matheus Tavares
2020-03-17 18:57   ` [PATCH v2 3/3] dir: update outdated comments about untracked cache Matheus Tavares

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6fee28469e49d501e5184162bc820350f60cc3de.1584329834.git.matheus.bernardino@usp.br \
    --to=matheus.bernardino@usp.br \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).