summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-12-19 15:13:00 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-12-19 15:13:00 +0000
commitb48f7c652516d74d3c0efbb33a5a4bb55cae6bef (patch)
treed64e03d952b94fece518fe4235b5206cd143c0d1 /usr.bin/cvs
parente73a0e699c57f06d47ec44ec7eb9e9958892d616 (diff)
- Introduce a way for the command code to recognize what the server replied.
- Modify the add command so it uses the above method to correctly enter added files in CVS/Entries if in a remote setup. ok xsa@ ... And no a shark didnt eat me.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/add.c27
-rw-r--r--usr.bin/cvs/client.c6
-rw-r--r--usr.bin/cvs/remote.h7
3 files changed, 37 insertions, 3 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index e0930e5099e..13025a8fe41 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.62 2006/12/04 09:51:21 xsa Exp $ */
+/* $OpenBSD: add.c,v 1.63 2006/12/19 15:12:59 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -26,6 +26,7 @@
extern char *__progname;
void cvs_add_local(struct cvs_file *);
+void cvs_add_entry(struct cvs_file *);
static void add_directory(struct cvs_file *);
static void add_file(struct cvs_file *);
@@ -89,12 +90,36 @@ cvs_add(int argc, char **argv)
cvs_client_senddir(".");
cvs_client_send_request("add");
cvs_client_get_responses();
+
+ if (server_response == SERVER_OK) {
+ cr.fileproc = cvs_add_entry;
+ cvs_file_run(argc, argv, &cr);
+ }
}
return (0);
}
void
+cvs_add_entry(struct cvs_file *cf)
+{
+ int l;
+ char *entry;
+ CVSENTRIES *entlist;
+
+ if (cf->file_type == CVS_DIR) {
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ l = snprintf(entry, CVS_ENT_MAXLINELEN,
+ "D/%s/////", cf->file_name);
+ entlist = cvs_ent_open(cf->file_wd);
+ cvs_ent_add(entlist, entry);
+ cvs_ent_close(entlist, ENT_SYNC);
+ } else {
+ add_entry(cf);
+ }
+}
+
+void
cvs_add_local(struct cvs_file *cf)
{
cvs_log(LP_TRACE, "cvs_add_local(%s)", cf->file_path);
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c
index ce5792617bd..847ac750544 100644
--- a/usr.bin/cvs/client.c
+++ b/usr.bin/cvs/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.36 2006/12/19 14:11:21 xsa Exp $ */
+/* $OpenBSD: client.c,v 1.37 2006/12/19 15:12:59 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -109,6 +109,8 @@ static int cvs_client_inlog_fd = -1;
static int cvs_client_outlog_fd = -1;
+int server_response = SERVER_OK;
+
static char *
client_get_supported_responses(void)
{
@@ -534,12 +536,14 @@ void
cvs_client_ok(char *data)
{
end_of_response = 1;
+ server_response = SERVER_OK;
}
void
cvs_client_error(char *data)
{
end_of_response = 1;
+ server_response = SERVER_ERROR;
}
void
diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h
index d53ea308ca1..3f06631c5f0 100644
--- a/usr.bin/cvs/remote.h
+++ b/usr.bin/cvs/remote.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.h,v 1.14 2006/12/19 14:11:21 xsa Exp $ */
+/* $OpenBSD: remote.h,v 1.15 2006/12/19 15:12:59 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -37,6 +37,11 @@ struct cvs_resp {
#define REQ_NEEDED 0x01
#define RESP_NEEDED 0x01
+extern int server_response;
+
+#define SERVER_OK 0
+#define SERVER_ERROR 1
+
void cvs_client_connect_to_server(void);
void cvs_client_disconnect(void);
void cvs_client_send_request(char *, ...);