summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-07-08 00:34:21 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-07-08 00:34:21 +0000
commita46fceb5b50ca81049864a9aefb8b458f1ca6384 (patch)
tree8665ce545e21a7549edebfb37fce9a4e89082ff3 /usr.bin
parent10157221a2659d2c272524b419801c7f9718ef12 (diff)
allow update in remote mode to work a bit better and
create any missing directories or new directories with -d
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/client.c37
-rw-r--r--usr.bin/cvs/remote.c9
2 files changed, 44 insertions, 2 deletions
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c
index 0ef1f5fb4ad..04135d775b0 100644
--- a/usr.bin/cvs/client.c
+++ b/usr.bin/cvs/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.9 2006/07/07 17:37:17 joris Exp $ */
+/* $OpenBSD: client.c,v 1.10 2006/07/08 00:34:20 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -90,6 +90,7 @@ struct cvs_req cvs_requests[] = {
{ "", -1, NULL, 0 }
};
+static void client_check_directory(char *);
static char *client_get_supported_responses(void);
static char *lastdir = NULL;
static int end_of_response = 0;
@@ -120,6 +121,35 @@ client_get_supported_responses(void)
return (d);
}
+static void
+client_check_directory(char *data)
+{
+ int l;
+ CVSENTRIES *entlist;
+ char *entry, *parent, *base;
+
+ STRIP_SLASH(data);
+
+ cvs_mkpath(data);
+
+ if ((base = basename(data)) == NULL)
+ fatal("client_check_directory: overflow");
+
+ if ((parent = dirname(data)) == NULL)
+ fatal("client_check_directory: overflow");
+
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ l = snprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", base);
+ if (l == -1 || l >= CVS_ENT_MAXLINELEN)
+ fatal("client_check_directory: overflow");
+
+ entlist = cvs_ent_open(parent);
+ cvs_ent_add(entlist, entry);
+ cvs_ent_close(entlist, ENT_SYNC);
+
+ xfree(entry);
+}
+
void
cvs_client_connect_to_server(void)
{
@@ -303,6 +333,9 @@ cvs_client_sendfile(struct cvs_file *cf)
cvs_log(LP_TRACE, "cvs_client_sendfile(%s)", cf->file_path);
cvs_remote_classify_file(cf);
+ if (cf->file_type == CVS_DIR)
+ return;
+
if (cf->file_ent != NULL) {
if (cf->file_status == FILE_ADDED) {
len = strlcpy(rev, "0", sizeof(rev));
@@ -489,6 +522,8 @@ cvs_client_updated(char *data)
cvs_log(LP_TRACE, "cvs_client_updated(%s)", data);
+ client_check_directory(data);
+
rpath = cvs_remote_input();
entry = cvs_remote_input();
mode = cvs_remote_input();
diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c
index 4d00a12ed53..8d39288e9eb 100644
--- a/usr.bin/cvs/remote.c
+++ b/usr.bin/cvs/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.1 2006/07/07 17:37:17 joris Exp $ */
+/* $OpenBSD: remote.c,v 1.2 2006/07/08 00:34:20 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -192,6 +192,13 @@ cvs_remote_classify_file(struct cvs_file *cf)
return;
}
+ if (cf->file_ent != NULL) {
+ if (cf->file_ent->ce_type == CVS_ENT_DIR)
+ cf->file_type = CVS_DIR;
+ else
+ cf->file_type = CVS_FILE;
+ }
+
if (cf->fd != -1 && cf->file_ent != NULL) {
if (fstat(cf->fd, &st) == -1)
fatal("cvs_remote_classify_file(%s): %s", cf->file_path,