git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Derrick Stolee" <stolee@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 1/2] sparse-index.c: remove set_index_sparse_config()
Date: Wed,  5 May 2021 14:11:58 +0200	[thread overview]
Message-ID: <patch-1.2-6872fd6a59b-20210505T121028Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.2-00000000000-20210505T121028Z-avarab@gmail.com>

Remove the set_index_sparse_config() function by folding it into
set_sparse_index_config(), which was its only user.

Since 122ba1f7b52 (sparse-checkout: toggle sparse index from builtin,
2021-03-30) the flow of this code hasn't made much sense, we'd get
"enabled" in set_sparse_index_config(), proceed to call
set_index_sparse_config() with it.

There we'd call prepare_repo_settings() and set
"repo->settings.sparse_index = 1", only to needlessly call
prepare_repo_settings() again in set_sparse_index_config() (where it
would early abort), and finally setting "repo->settings.sparse_index =
enabled".

Instead we can just call prepare_repo_settings() once, and set the
variable to "enabled" in the first place.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 sparse-index.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/sparse-index.c b/sparse-index.c
index 6f21397e2ee..b0d5dc5f081 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -102,7 +102,7 @@ static int convert_to_sparse_rec(struct index_state *istate,
 	return num_converted - start_converted;
 }
 
-static int set_index_sparse_config(struct repository *repo, int enable)
+int set_sparse_index_config(struct repository *repo, int enable)
 {
 	int res;
 	char *config_path = repo_git_path(repo, "config.worktree");
@@ -111,15 +111,6 @@ static int set_index_sparse_config(struct repository *repo, int enable)
 					    enable ? "true" : NULL);
 	free(config_path);
 
-	prepare_repo_settings(repo);
-	repo->settings.sparse_index = 1;
-	return res;
-}
-
-int set_sparse_index_config(struct repository *repo, int enable)
-{
-	int res = set_index_sparse_config(repo, enable);
-
 	prepare_repo_settings(repo);
 	repo->settings.sparse_index = enable;
 	return res;
-- 
2.31.1.838.g7ac6e98bb53


  reply	other threads:[~2021-05-05 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 12:11 [PATCH 0/2] sparse-index.c: minor prepare_repo_settings() fixes Ævar Arnfjörð Bjarmason
2021-05-05 12:11 ` Ævar Arnfjörð Bjarmason [this message]
2021-05-05 14:01   ` [PATCH 1/2] sparse-index.c: remove set_index_sparse_config() Derrick Stolee
2021-05-05 12:11 ` [PATCH 2/2] sparse-index.c: don't call prepare_repo_settings() twice in a row Ævar Arnfjörð Bjarmason
2021-05-05 14:00   ` Derrick Stolee
2021-05-06  3:55     ` Junio C Hamano
2021-05-06  8:49     ` Ævar Arnfjörð Bjarmason
2021-05-17 17:31       ` Derrick Stolee

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=patch-1.2-6872fd6a59b-20210505T121028Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /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).