git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] transport: Use is_bundle instead of !is_gitfile
@ 2011-10-13 20:26 Phil Hord
  2011-10-13 20:26 ` [PATCH 1/1] transport: Add is_bundle() to detect bundle urls Phil Hord
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Hord @ 2011-10-13 20:26 UTC (permalink / raw
  To: Git List, Junio C Hamano; +Cc: Phil Hord

I'm not sure where this patch should go now since I see my
original patchset on both next and pu.  Should I re-roll the
original series with this one merged in, or just submit this
one isolated, as I am doing here?

Pardon my newbieness.

Phil Hord (1):
  transport: Add is_bundle() to detect bundle urls

 bundle.c    |   16 ++++++++++++++++
 bundle.h    |    1 +
 transport.c |   10 +---------
 3 files changed, 18 insertions(+), 9 deletions(-)

-- 
1.7.7.334.g311c9.dirty

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] transport: Add is_bundle() to detect bundle urls
  2011-10-13 20:26 [PATCH 0/1] transport: Use is_bundle instead of !is_gitfile Phil Hord
@ 2011-10-13 20:26 ` Phil Hord
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Hord @ 2011-10-13 20:26 UTC (permalink / raw
  To: Git List, Junio C Hamano; +Cc: Phil Hord

Transport decides that any local url which is a file
must be a bundle.  This is wrong if the local url is a
gitfile. Teach transport to verify the file is
really a bundle instead of just assuming it is so.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phil Hord <hordp@cisco.com>
---
 bundle.c    |   16 ++++++++++++++++
 bundle.h    |    1 +
 transport.c |   10 +---------
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/bundle.c b/bundle.c
index f82baae..cc0624d 100644
--- a/bundle.c
+++ b/bundle.c
@@ -23,6 +23,22 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,
 	list->nr++;
 }
 
+int is_bundle(const char *path)
+{
+	char buffer[100];
+	FILE *ffd = fopen(path, "rb");
+	int ret=1;
+
+	if (!ffd)
+		return 0;
+
+	if (!fgets(buffer, sizeof(buffer), ffd) ||
+			strcmp(buffer, bundle_signature))
+		ret=0;
+	fclose(ffd);
+	return ret;
+}
+
 /* returns an fd */
 int read_bundle_header(const char *path, struct bundle_header *header)
 {
diff --git a/bundle.h b/bundle.h
index c5a22c8..35aa0eb 100644
--- a/bundle.h
+++ b/bundle.h
@@ -14,6 +14,7 @@ struct bundle_header {
 	struct ref_list references;
 };
 
+int is_bundle(const char *path);
 int read_bundle_header(const char *path, struct bundle_header *header);
 int create_bundle(struct bundle_header *header, const char *path,
 		int argc, const char **argv);
diff --git a/transport.c b/transport.c
index 57138d9..c76f5b7 100644
--- a/transport.c
+++ b/transport.c
@@ -881,14 +881,6 @@ static int is_gitfile(const char *url)
 	return !prefixcmp(buf, "gitdir: ");
 }
 
-static int is_file(const char *url)
-{
-	struct stat buf;
-	if (stat(url, &buf))
-		return 0;
-	return S_ISREG(buf.st_mode);
-}
-
 static int external_specification_len(const char *url)
 {
 	return strchr(url, ':') - url;
@@ -929,7 +921,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 		ret->fetch = fetch_objs_via_rsync;
 		ret->push = rsync_transport_push;
 		ret->smart_options = NULL;
-	} else if (is_local(url) && is_file(url) && !is_gitfile(url)) {
+	} else if (is_local(url) && is_bundle(url)) {
 		struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
 		ret->data = data;
 		ret->get_refs_list = get_refs_from_bundle;
-- 
1.7.7.334.g311c9.dirty

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-13 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-13 20:26 [PATCH 0/1] transport: Use is_bundle instead of !is_gitfile Phil Hord
2011-10-13 20:26 ` [PATCH 1/1] transport: Add is_bundle() to detect bundle urls Phil Hord

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).