* [PATCH] One Git To Rule Them All - Prep 2
@ 2005-06-01 5:59 Jason McMullan
0 siblings, 0 replies; only message in thread
From: Jason McMullan @ 2005-06-01 5:59 UTC (permalink / raw)
To: git
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-06-01 5:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-01 5:59 [PATCH] One Git To Rule Them All - Prep 2 Jason McMullan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox