From: Jason McMullan <jason.mcmullan@timesys.com>
To: git@vger.kernel.org
Subject: [PATCH] One Git To Rule Them All - Prep 2
Date: Wed, 1 Jun 2005 01:59:56 -0400 [thread overview]
Message-ID: <20050601055956.GA15845@port.evillabs.net> (raw)
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;
reply other threads:[~2005-06-01 5:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050601055956.GA15845@port.evillabs.net \
--to=jason.mcmullan@timesys.com \
--cc=git@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox