Thread (40 messages) flat view 40 messages, 2 authors, 2016-06-15
STALE3734d

[RFC PATCH 10/15] sparse-repo: Provide a function to record sparse limiting arguments

From: Elijah Newren <hidden>
Date: 2016-06-15 22:49:29
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Elijah Newren <redacted>
---
 sparse-repo.c |   20 ++++++++++++++++++++
 sparse-repo.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/sparse-repo.c b/sparse-repo.c
index 18ea976..c983096 100644
--- a/sparse-repo.c
+++ b/sparse-repo.c
@@ -5,6 +5,26 @@
 
 #define SPARSE_FILE "sparse-limits"
 
+void record_sparse_limits(const char *quoted_argv)
+{
+	int fd, len;
+	char *sparse_file = git_path(SPARSE_FILE);
+
+	/* FIXME: sq_quote_argv puts a leading space in front of quoted
+	 * arguments, but sq_dequote_to_argv chokes on it.  Maybe sq_quote_argv
+	 * should be fixed?
+	 */
+	if (*quoted_argv == ' ')
+		quoted_argv++;
+	len = strlen(quoted_argv);
+
+	fd = open(sparse_file, O_WRONLY | O_CREAT, 0666);
+	if (fd < 0 || write_in_full(fd, quoted_argv, len) != len)
+		die_errno("could not write %s", sparse_file);
+	xwrite(fd, "\n", 1);
+	close(fd);
+}
+
 void register_sparse_limits(const char **revlist_argv)
 {
 	if (revlist_argv != git_sparse_limits) {
diff --git a/sparse-repo.h b/sparse-repo.h
index ed9018a..2df175f 100644
--- a/sparse-repo.h
+++ b/sparse-repo.h
@@ -1,3 +1,4 @@
+void record_sparse_limits(const char *quoted_argv);
 void register_sparse_limits(const char **revlist_argv);
 void register_quoted_sparse_limits(char *quoted_argv);
 void check_sparse_repo(void);
-- 
1.7.2.2.140.gd06af
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help