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

[PATCH] One Git To Rule Them All - Prep 2

From
JMJason McMullan <jason.mcmullan@timesys.com>
Date
Jun 1, 2005, 05:59 UTC
Message-ID
<20050601055956.GA15845@port.evillabs.net>
one-git prep patch 2/2

Make pull.c usable in one-git by making 'fetch' an overridable function pointer, instead of an external function.

Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com>
diff --git a/http-pull.c b/http-pull.c
--- a/http-pull.c
+++ b/http-pull.c
@@ -39,7 +39,7 @@ static size_t fwrite_sha1_file(void *ptr
 	return size;
 }
 
-int fetch(unsigned char *sha1)
+static int my_fetch(unsigned char *sha1)
 {
 	char *hex = sha1_to_hex(sha1);
 	char *filename = sha1_file_name(sha1);
@@ -98,6 +98,8 @@ int main(int argc, char **argv)
 	char *url;
 	int arg = 1;
 
+	fetch = my_fetch;
+
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't') {
 			get_tree = 1;
diff --git a/local-pull.c b/local-pull.c
--- a/local-pull.c
+++ b/local-pull.c
@@ -11,7 +11,7 @@ static int use_filecopy = 1;
 
 static char *path;
 
-int fetch(unsigned char *sha1)
+static int my_fetch(unsigned char *sha1)
 {
 	static int object_name_start = -1;
 	static char filename[PATH_MAX];
@@ -87,6 +87,8 @@ int main(int argc, char **argv)
 	char *commit_id;
 	int arg = 1;
 
+	fetch = my_fetch;
+
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't')
 			get_tree = 1;
diff --git a/pull.c b/pull.c
--- a/pull.c
+++ b/pull.c
@@ -14,6 +14,14 @@ static const char commitS[] = "commit";
 static const char treeS[] = "tree";
 static const char blobS[] = "blob";
 
+int null_fetch(unsigned char *sha1)
+{
+	fprintf(stderr,"fetch() routine not implemented.\n");
+	return -1;
+}
+
+int (*fetch)(unsigned char *sha1) = null_fetch;
+
 void pull_say(const char *fmt, const char *hex) {
 	if (get_verbosely)
 		fprintf(stderr, fmt, hex);
diff --git a/pull.h b/pull.h
--- a/pull.h
+++ b/pull.h
@@ -2,7 +2,7 @@
 #define PULL_H
 
 /** To be provided by the particular implementation. **/
-extern int fetch(unsigned char *sha1);
+extern int (*fetch)(unsigned char *sha1);
 
 /** Set to fetch the target tree. */
 extern int get_tree;
diff --git a/rpull.c b/rpull.c
--- a/rpull.c
+++ b/rpull.c
@@ -6,7 +6,7 @@
 static int fd_in;
 static int fd_out;
 
-int fetch(unsigned char *sha1)
+static int my_fetch(unsigned char *sha1)
 {
 	int ret;
 	write(fd_out, sha1, 20);
@@ -22,6 +22,8 @@ int main(int argc, char **argv)
 	char *url;
 	int arg = 1;
 
+	fetch = my_fetch;
+
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't') {
 			get_tree = 1;
Message 1 of 1 in “One Git To Rule Them All - Prep 2”
  1. One Git To Rule Them All - Prep 2Jason McMullan, Jun 1, 2005

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.