# [PATCH] Add NO_RSYNC to allow building without rsync

6 messages from 2008-07-30 to 2008-07-30. Participants: Aidan Van Dyk, Linus Torvalds, Junio C Hamano, Boyd Lynn Gerber.
Thread: https://gitlist.dev/t/14765

## Aidan Van Dyk, 2008-07-30 18:52

Subject: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <20080730185225.GG10399@yugib.highrise.ca>
URL: https://gitlist.dev/e/20080730185225.GG10399%40yugib.highrise.ca

```
This is similar to NO_CURL.

Signed-off-by: Aidan Van Dyk <aidan@highrise.ca>
---

I came about this because SCO OpenServer doesnt' have mkdtemp.  But I never use
rsync, so making it optional was an easy fix.

 Makefile    |    4 ++++
 transport.c |    9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 798a2f2..b0a2985 100644
--- a/Makefile
+++ b/Makefile
@@ -789,6 +789,10 @@ else
        CC_LD_DYNPATH = -R
 endif

+ifdef NO_RSYNC
+       BASIC_CFLAGS += -DNO_RSYNC
+endif
+
 ifdef NO_CURL
        BASIC_CFLAGS += -DNO_CURL
 else
diff --git a/transport.c b/transport.c
index 6eb65b8..867b01f 100644
--- a/transport.c
+++ b/transport.c
@@ -142,6 +142,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
        }
 }

+#ifndef NO_RSYNC
 static struct ref *get_refs_via_rsync(struct transport *transport)
 {
        struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
@@ -232,6 +233,7 @@ static int fetch_objs_via_rsync(struct transport *transport,

        return result;
 }
+#endif

 static int write_one_ref(const char *name, const unsigned char *sha1,
                int flags, void *data)
@@ -276,6 +278,7 @@ static int write_refs_to_temp_dir(struct strbuf *temp_dir,
        return 0;
 }

+#ifndef NO_RSYNC
 static int rsync_transport_push(struct transport *transport,
                int refspec_nr, const char **refspec, int flags)
 {
@@ -345,6 +348,7 @@ static int rsync_transport_push(struct transport *transport,

        return result;
 }
+#endif

 /* Generic functions for using commit walkers */

@@ -731,10 +735,13 @@ struct transport *transport_get(struct remote *remote, const char *url)
        ret->url = url;

        if (!prefixcmp(url, "rsync://")) {
+#ifdef NO_RSYNC
+               error("git was compiled without rsync support.");
+#else
                ret->get_refs_list = get_refs_via_rsync;
                ret->fetch = fetch_objs_via_rsync;
                ret->push = rsync_transport_push;
-
+#endif
        } else if (!prefixcmp(url, "http://")
                || !prefixcmp(url, "https://")
                || !prefixcmp(url, "ftp://")) {
--
1.6.0.rc1.dirty

```

## Linus Torvalds, 2008-07-30 19:33

Subject: Re: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <alpine.LFD.1.10.0807301231050.3334@nehalem.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.1.10.0807301231050.3334%40nehalem.linux-foundation.org
In-Reply-To: <20080730185225.GG10399@yugib.highrise.ca>

```


On Wed, 30 Jul 2008, Aidan Van Dyk wrote:
> 
> I came about this because SCO OpenServer doesnt' have mkdtemp.  But I never use
> rsync, so making it optional was an easy fix.

Hmm. Without mkdtemp(), maybe you could just do a trivial compat function 
somethin glike

	char *git_mkdtemp(char *template)
	{
		char *n = mktemp(template);
		if (mkdir(n))
			n = NULL;
		return n;
	}

instead?

		Linus

```

## Aidan Van Dyk, 2008-07-30 19:49

Subject: Re: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <20080730194905.GI10399@yugib.highrise.ca>
URL: https://gitlist.dev/e/20080730194905.GI10399%40yugib.highrise.ca
In-Reply-To: <alpine.LFD.1.10.0807301231050.3334@nehalem.linux-foundation.org>

```
* Linus Torvalds <torvalds@linux-foundation.org> [080730 15:42]:
 
> Hmm. Without mkdtemp(), maybe you could just do a trivial compat function 
> somethin glike
> 
> 	char *git_mkdtemp(char *template)
> 	{
> 		char *n = mktemp(template);
> 		if (mkdir(n))
> 			n = NULL;
> 		return n;
> 	}
> 
> instead?


And as I go to whip that up (ya, I'm lazy and just needed a prod), I see
it's already done:

# Define NO_MKDTEMP if you don't have mkdtemp in the C library.

But since rsync isn't available on this compile anyways, I still think
NO_RSYNC is worth having on it's own, just like NO_CURL or NO_TCLTK

a.

-- 
Aidan Van Dyk                                             Create like a god,
aidan@highrise.ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.

```

## Junio C Hamano, 2008-07-30 20:11

Subject: Re: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <7vod4f3zfu.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vod4f3zfu.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080730185225.GG10399@yugib.highrise.ca>

```
Aidan Van Dyk <aidan@highrise.ca> writes:

> This is similar to NO_CURL.

I am not sure if this is a good change.

We link with libcurl so supporting NO_CURL makes sense for an environment
without the library, but for rsync transport we just spawn it as a
separate process.  The net effect on a machine without rsync installed is
the same (you cannot use rsync transport), but you can later choose to
install rsync and things will start working without recompiling git.

> Signed-off-by: Aidan Van Dyk <aidan@highrise.ca>
> ---
>
> I came about this because SCO OpenServer doesnt' have mkdtemp.  But I never use
> rsync, so making it optional was an easy fix.

Perhaps "make NO_MKDTEMP=YesPlease" is a much better fix for your
particular environment?

The patch is seriously whitespace damaged, in any case.

```

## Aidan Van Dyk, 2008-07-30 20:49

Subject: Re: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <20080730204948.GK10399@yugib.highrise.ca>
URL: https://gitlist.dev/e/20080730204948.GK10399%40yugib.highrise.ca
In-Reply-To: <7vod4f3zfu.fsf@gitster.siamese.dyndns.org>

```
* Junio C Hamano <gitster@pobox.com> [080730 16:11]:

> > I came about this because SCO OpenServer doesnt' have mkdtemp.  But I never use
> > rsync, so making it optional was an easy fix.
> 
> Perhaps "make NO_MKDTEMP=YesPlease" is a much better fix for your
> particular environment?

Yes, I found that out after...

> The patch is seriously whitespace damaged, in any case.

Ooops... copy-n-paste from git-format-patch|more on some crappy sco terminal
through a screen session...  I guess someone in there translated tabs to
spaces...

a.

-- 
Aidan Van Dyk                                             Create like a god,
aidan@highrise.ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.

```

## Boyd Lynn Gerber, 2008-07-30 21:42

Subject: Re: [PATCH] Add NO_RSYNC to allow building without rsync
Message-ID: <alpine.LNX.1.10.0807301539160.13032@xenau.zenez.com>
URL: https://gitlist.dev/e/alpine.LNX.1.10.0807301539160.13032%40xenau.zenez.com
In-Reply-To: <20080730204948.GK10399@yugib.highrise.ca>

```
On Wed, 30 Jul 2008, Aidan Van Dyk wrote:
> * Junio C Hamano <gitster@pobox.com> [080730 16:11]:
> > > I came about this because SCO OpenServer doesnt' have mkdtemp.  But I never use
> > > rsync, so making it optional was an easy fix.
> > 
> > Perhaps "make NO_MKDTEMP=YesPlease" is a much better fix for your
> > particular environment?
> 
> Yes, I found that out after...
> 
> > The patch is seriously whitespace damaged, in any case.
> 
> Ooops... copy-n-paste from git-format-patch|more on some crappy sco terminal
> through a screen session...  I guess someone in there translated tabs to
> spaces...

I do have rsync.  I use it all the time on OpenServer 6.  I have automated 
rsync backups of certain Openserver 6 machines.

tech0 > rsync --version
rsync  version 3.0.2  protocol version 30
Copyright (C) 1996-2008 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, no IPv6, batchfiles, inplace,
    append, ACLs, no xattrs, iconv, no symtimes

tech0.zenez.com and osr600.zenez.com are OpenServer 6 machines.

--
Boyd Gerber <gerberb@zenez.com>
ZENEZ	1042 East Fort Union #135, Midvale Utah  84047

```
