From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: newren@gmaill.com, peff@peff.net, me@ttaylorr.com,
jrnieder@gmail.com, Derrick Stolee <dstolee@microsoft.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH 03/10] sparse-checkout: move code from unpack-trees.c
Date: Thu, 07 May 2020 13:17:35 +0000 [thread overview]
Message-ID: <444a6b5f894f28e96f713e5caccba18e1ea3b3eb.1588857462.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.627.git.1588857462.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
There is no need to have two ways to load the sparse-checkout patterns,
especially duplicating the info/sparse-checkout filename. Move this code
out of unpack-trees.c and into sparse-checkout.c.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
sparse-checkout.c | 12 ++++++++++++
sparse-checkout.h | 1 +
unpack-trees.c | 7 ++-----
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/sparse-checkout.c b/sparse-checkout.c
index 5ada307b42c..875b620568d 100644
--- a/sparse-checkout.c
+++ b/sparse-checkout.c
@@ -33,6 +33,18 @@ void write_patterns_to_file(FILE *fp, struct pattern_list *pl)
}
}
+int populate_sparse_checkout_patterns(struct pattern_list *pl)
+{
+ int result;
+ char *sparse = get_sparse_checkout_filename();
+
+ pl->use_cone_patterns = core_sparse_checkout_cone;
+ result = add_patterns_from_file_to_list(sparse, "", 0, pl, NULL);
+ free(sparse);
+
+ return result;
+}
+
int update_working_directory(struct pattern_list *pl)
{
enum update_sparsity_result result;
diff --git a/sparse-checkout.h b/sparse-checkout.h
index 4148832760d..e0c840f07f9 100644
--- a/sparse-checkout.h
+++ b/sparse-checkout.h
@@ -7,6 +7,7 @@
struct pattern_list;
char *get_sparse_checkout_filename(void);
+int populate_sparse_checkout_patterns(struct pattern_list *pl);
void write_patterns_to_file(FILE *fp, struct pattern_list *pl);
int update_working_directory(struct pattern_list *pl);
int write_patterns_and_update(struct pattern_list *pl);
diff --git a/unpack-trees.c b/unpack-trees.c
index 4f880f2da90..6f9bdeb57a0 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -16,6 +16,7 @@
#include "fsmonitor.h"
#include "object-store.h"
#include "promisor-remote.h"
+#include "sparse-checkout.h"
/*
* Error messages expected by scripts out of plumbing commands such as
@@ -1550,14 +1551,10 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
static void populate_from_existing_patterns(struct unpack_trees_options *o,
struct pattern_list *pl)
{
- char *sparse = git_pathdup("info/sparse-checkout");
-
- pl->use_cone_patterns = core_sparse_checkout_cone;
- if (add_patterns_from_file_to_list(sparse, "", 0, pl, NULL) < 0)
+ if (populate_sparse_checkout_patterns(pl) < 0)
o->skip_sparse_checkout = 1;
else
o->pl = pl;
- free(sparse);
}
--
gitgitgadget
next prev parent reply other threads:[~2020-05-07 13:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 13:17 [PATCH 00/10] [RFC] In-tree sparse-checkout definitions Derrick Stolee via GitGitGadget
2020-05-07 13:17 ` [PATCH 01/10] unpack-trees: avoid array out-of-bounds error Derrick Stolee via GitGitGadget
2020-05-07 22:27 ` Junio C Hamano
2020-05-08 12:19 ` Derrick Stolee
2020-05-08 15:09 ` Junio C Hamano
2020-05-20 16:32 ` Elijah Newren
2020-05-07 13:17 ` [PATCH 02/10] sparse-checkout: move code from builtin Derrick Stolee via GitGitGadget
2020-05-07 13:17 ` Derrick Stolee via GitGitGadget [this message]
2020-05-07 13:17 ` [PATCH 04/10] sparse-checkout: allow in-tree definitions Derrick Stolee via GitGitGadget
2020-05-07 22:58 ` Junio C Hamano
2020-05-08 15:40 ` Derrick Stolee
2020-05-20 17:52 ` Elijah Newren
2020-06-17 23:07 ` Elijah Newren
2020-06-18 8:18 ` Son Luong Ngoc
2020-05-07 13:17 ` [PATCH 05/10] sparse-checkout: automatically update in-tree definition Derrick Stolee via GitGitGadget
2020-05-20 16:28 ` Elijah Newren
2020-05-07 13:17 ` [PATCH 06/10] sparse-checkout: use oidset to prevent repeat blobs Derrick Stolee via GitGitGadget
2020-05-20 16:40 ` Elijah Newren
2020-05-21 3:49 ` Elijah Newren
2020-05-21 17:54 ` Derrick Stolee
2020-05-07 13:17 ` [PATCH 07/10] sparse-checkout: define in-tree dependencies Derrick Stolee via GitGitGadget
2020-05-20 18:10 ` Elijah Newren
2020-05-30 17:26 ` Elijah Newren
2020-05-07 13:17 ` [PATCH 08/10] Makefile: skip git-gui if dir is missing Derrick Stolee via GitGitGadget
2020-05-07 13:17 ` [PATCH 09/10] Makefile: disable GETTEXT when 'po' " Derrick Stolee via GitGitGadget
2020-05-07 13:17 ` [PATCH 10/10] .sparse: add in-tree sparse-checkout for Git Derrick Stolee via GitGitGadget
2020-05-20 17:38 ` [PATCH 00/10] [RFC] In-tree sparse-checkout definitions Elijah Newren
2020-06-17 23:14 ` Elijah Newren
2020-06-18 1:42 ` Derrick Stolee
2020-06-18 1:59 ` Elijah Newren
2020-06-18 3:01 ` Derrick Stolee
2020-06-18 5:03 ` Elijah Newren
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=444a6b5f894f28e96f713e5caccba18e1ea3b3eb.1588857462.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=me@ttaylorr.com \
--cc=newren@gmaill.com \
--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).