Instead use cvsroot_is_local() and cvsroot_is_remote().
-/* $OpenBSD: add.c,v 1.113 2016/10/13 20:51:25 fcambus Exp $ */
+/* $OpenBSD: add.c,v 1.114 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_add_remote;
flags = 0;
(added_files == 1) ? "this file" : "these files");
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_senddir(".");
cvs_client_send_files(argv, argc);
cvs_client_send_request("add");
}
}
- if (added == 1 && current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (added == 1 && cvsroot_is_local()) {
(void)xsnprintf(msg, sizeof(msg),
"Directory %s added to the repository", cf->file_rpath);
-/* $OpenBSD: admin.c,v 1.67 2016/10/13 20:51:25 fcambus Exp $ */
+/* $OpenBSD: admin.c,v 1.68 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("admin");
-/* $OpenBSD: annotate.c,v 1.68 2017/05/31 16:14:37 joris Exp $ */
+/* $OpenBSD: annotate.c,v 1.69 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cr.flags = flags;
- if (cvs_cmdop == CVS_OP_ANNOTATE ||
- current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvs_cmdop == CVS_OP_ANNOTATE || cvsroot_is_local()) {
if (argc > 0)
cvs_file_run(argc, argv, &cr);
else
cvs_file_run(1, &arg, &cr);
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
-/* $OpenBSD: checkout.c,v 1.170 2015/11/05 09:48:21 nicm Exp $ */
+/* $OpenBSD: checkout.c,v 1.171 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
build_dirs = print_stdout ? 0 : 1;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
if (cvs_specified_tag != NULL)
-/* $OpenBSD: commit.c,v 1.157 2017/05/31 16:48:16 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.158 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
if (RB_EMPTY(&files_affected))
return (0);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
if (logmsg == NULL) {
logmsg = cvs_logmsg_create(NULL, &files_added,
&files_removed, &files_modified);
cvs_log(LP_TRACE, "cvs_commit_check_files(%s)", cf->file_path);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL)
+ if (cvsroot_is_remote())
cvs_remote_classify_file(cf);
else
cvs_file_classify(cf, cvs_directory_tag);
return;
}
- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvsroot_is_local()) {
tag = cvs_directory_tag;
if (cf->file_ent != NULL)
tag = cf->file_ent->ce_tag;
-/* $OpenBSD: cvs.c,v 1.158 2016/09/04 16:39:50 tb Exp $ */
+/* $OpenBSD: cvs.c,v 1.159 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
fatal("or set the CVSROOT environment variable.");
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cmdp->cmd(cmd_argc, cmd_argv);
cvs_cleanup();
return (0);
-/* $OpenBSD: cvs.h,v 1.183 2017/05/28 17:11:34 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.184 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
/* root.c */
struct cvsroot *cvsroot_get(const char *);
+int cvsroot_is_local(void);
+int cvsroot_is_remote(void);
/* logmsg.c */
char *cvs_logmsg_read(const char *);
-/* $OpenBSD: diff.c,v 1.162 2016/10/13 20:51:25 fcambus Exp $ */
+/* $OpenBSD: diff.c,v 1.163 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
flags |= CR_REPO;
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
diff_rev1 = diff_rev2 = NULL;
- if (cvs_cmdop == CVS_OP_DIFF ||
- current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvs_cmdop == CVS_OP_DIFF || cvsroot_is_local()) {
if (argc > 0)
cvs_file_run(argc, argv, &cr);
else
cvs_file_run(1, &arg, &cr);
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
-/* $OpenBSD: edit.c,v 1.52 2016/10/13 20:51:25 fcambus Exp $ */
+/* $OpenBSD: edit.c,v 1.53 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org>
*
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("edit");
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("editors");
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("unedit");
-/* $OpenBSD: file.c,v 1.271 2017/05/29 17:18:56 joris Exp $ */
+/* $OpenBSD: file.c,v 1.272 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
if (cf->fd != -1)
cf->file_flags |= FILE_ON_DISK;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL ||
- cvs_server_active == 1)
+ if (cvsroot_is_remote() || cvs_server_active == 1)
cvs_validate_directory(cf->file_path);
return (cf);
goto next;
}
}
- } else if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ } else if (cvsroot_is_local()) {
/*
* During checkout -p, do not use any locally
* available directories.
cvs_directory_tag =
xstrdup(cvs_specified_tag);
- if (current_cvsroot->cr_method ==
- CVS_METHOD_LOCAL) {
+ if (cvsroot_is_local()) {
cvs_get_repository_path(cf->file_wd,
repo, PATH_MAX);
cvs_repository_lock(repo,
}
walkrepo:
- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvsroot_is_local()) {
cvs_get_repository_path(cf->file_path, repo, PATH_MAX);
cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO));
}
cvs_file_walklist(&fl, cr);
cvs_file_freelist(&fl);
- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL &&
- (cmdp->cmd_flags & CVS_LOCK_REPO))
+ if (cvsroot_is_local() && (cmdp->cmd_flags & CVS_LOCK_REPO))
cvs_repository_unlock(repo);
if (cvs_directory_tag != NULL && cmdp->cmd_flags & CVS_USE_WDIR) {
-/* $OpenBSD: getlog.c,v 1.100 2016/10/15 22:20:17 millert Exp $ */
+/* $OpenBSD: getlog.c,v 1.101 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cr.flags = flags;
- if (cvs_cmdop == CVS_OP_LOG ||
- current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvs_cmdop == CVS_OP_LOG || cvsroot_is_local()) {
if (argc > 0)
cvs_file_run(argc, argv, &cr);
else
cvs_file_run(1, &arg, &cr);
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
-/* $OpenBSD: import.c,v 1.107 2017/05/28 17:11:34 joris Exp $ */
+/* $OpenBSD: import.c,v 1.108 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
logmsg = cvs_logmsg_create(NULL, NULL, NULL, NULL);
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cvs_client_send_request("Argument -b%s", IMPORT_DEFAULT_BRANCH);
-/* $OpenBSD: init.c,v 1.39 2015/01/16 06:40:07 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.40 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
if (argc > 1)
fatal("init does not take any extra arguments");
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cvs_client_send_request("init %s", current_cvsroot->cr_dir);
cvs_client_get_responses();
- } else
+ } else {
cvs_init_local();
+ }
return (0);
}
-/* $OpenBSD: release.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */
+/* $OpenBSD: release.c,v 1.43 2017/06/01 08:08:24 joris Exp $ */
/*-
* Copyright (c) 2005-2007 Xavier Santolaria <xsa@openbsd.org>
*
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("release");
-/* $OpenBSD: remove.c,v 1.83 2015/11/05 09:48:21 nicm Exp $ */
+/* $OpenBSD: remove.c,v 1.84 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
*
cvs_file_run(1, &arg, &cr);
}
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
else
cvs_file_run(1, &arg, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("remove");
-/* $OpenBSD: root.c,v 1.48 2015/01/16 06:40:07 deraadt Exp $ */
+/* $OpenBSD: root.c,v 1.49 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
return cvsroot_parse(line);
}
+
+int
+cvsroot_is_local(void)
+{
+ if (current_cvsroot == NULL)
+ fatal("cvsroot_is_local: no CVSROOT");
+
+ return (current_cvsroot->cr_method == CVS_METHOD_LOCAL);
+}
+
+int
+cvsroot_is_remote(void)
+{
+ if (current_cvsroot == NULL)
+ fatal("cvsroot_is_remote: no CVSROOT");
+
+ return (current_cvsroot->cr_method != CVS_METHOD_LOCAL);
+}
-/* $OpenBSD: status.c,v 1.99 2017/05/28 16:58:54 joris Exp $ */
+/* $OpenBSD: status.c,v 1.100 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005-2008 Xavier Santolaria <xsa@openbsd.org>
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvsroot_is_local()) {
flags |= CR_REPO;
cr.fileproc = cvs_status_local;
} else {
else
cvs_file_run(1, &arg, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("status");
-/* $OpenBSD: tag.c,v 1.86 2017/05/31 16:13:25 joris Exp $ */
+/* $OpenBSD: tag.c,v 1.87 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
*
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
-/* $OpenBSD: update.c,v 1.175 2017/05/29 17:18:56 joris Exp $ */
+/* $OpenBSD: update.c,v 1.176 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
argc -= optind;
argv += optind;
- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
+ if (cvsroot_is_local()) {
cr.enterdir = cvs_update_enterdir;
cr.leavedir = prune_dirs ? cvs_update_leavedir : NULL;
cr.fileproc = cvs_update_local;
else
cvs_file_run(1, &arg, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("update");
-/* $OpenBSD: util.c,v 1.159 2016/10/13 20:51:25 fcambus Exp $ */
+/* $OpenBSD: util.c,v 1.160 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
hd.h_data = NULL;
hash_table_enter(&created_directories, &hd);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL ||
- cvs_server_active == 1)
+ if (cvsroot_is_remote() || cvs_server_active == 1)
cvs_validate_directory(path);
dir = xstrdup(path);
size_t len;
char *sp, *dp, *dir, rpath[PATH_MAX];
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL ||
- cvs_server_active == 1)
+ if (cvsroot_is_remote() || cvs_server_active == 1)
cvs_validate_directory(path);
dir = xstrdup(path);
-/* $OpenBSD: version.c,v 1.25 2007/05/02 16:26:50 xsa Exp $ */
+/* $OpenBSD: version.c,v 1.26 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
if (argc > 1)
fatal("version does not take any extra arguments");
- if (current_cvsroot != NULL &&
- current_cvsroot->cr_method != CVS_METHOD_LOCAL)
+ if (current_cvsroot != NULL && cvsroot_is_remote())
cvs_printf("Client: ");
cvs_printf("%s\n", CVS_VERSION);
- if (current_cvsroot != NULL &&
- current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (current_cvsroot != NULL && cvsroot_is_remote()) {
cvs_client_connect_to_server();
cvs_client_send_request("version");
/* XXX: better way to handle server response? */
-/* $OpenBSD: watch.c,v 1.22 2011/12/27 13:59:01 nicm Exp $ */
+/* $OpenBSD: watch.c,v 1.23 2017/06/01 08:08:24 joris Exp $ */
/*
* Copyright (c) 2005-2007 Xavier Santolaria <xsa@openbsd.org>
*
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cr.enterdir = NULL;
cr.leavedir = NULL;
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_connect_to_server();
cr.fileproc = cvs_client_sendfile;
cvs_file_run(argc, argv, &cr);
- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
+ if (cvsroot_is_remote()) {
cvs_client_send_files(argv, argc);
cvs_client_senddir(".");
cvs_client_send_request("watchers");