commit - ec1fc282066c81c2ae67cedff55b819ff8886cd8
commit + 6becd17985c1bba6b5ad4b15965378d2fa5b54d6
blob - 0e665f95953ac4cc1f0f6a97331b5de8d00fb0bc
blob + 8c5b5a75328351dabed1b36f8461032cb1adeee8
--- got/got.1
+++ got/got.1
.Nm
are as follows:
.Bl -tag -width checkout
+.It Cm init Oo Fl b Ar branch Oc Ar repository-path
+Create a new empty repository at the specified
+.Ar repository-path .
+.Pp
+After
+.Cm got init ,
+the new repository must be populated before
+.Cm got checkout
+can be used.
+The
+.Cm got import
+command can be used to populate the new repository with data from
+a local directory.
+Alternatively, on a server running
+.Xr gotd 8 ,
+the new repository can be made available to
+.Xr got 1
+or
+.Xr git 1
+clients by adding the repository to
+.Xr gotd.conf 5
+and restarting
+.Xr gotd 8 .
+Clients may then clone the new repository from the server, populate the cloned
+repository, and then populate the new repository on the server via
+.Cm got send
+or
+.Cm git push .
+.Pp
+The options for
+.Cm got init
+are as follows:
+.Bl -tag -width Ds
+.It Fl b Ar branch
+Make the repository's HEAD reference point to the specified
+.Ar branch
+instead of the default branch
+.Dq main .
+.El
+.Pp
+The
+.Cm got init
+command is equivalent to
+.Cm gotadmin init .
.Tg im
.It Xo
.Cm import
e.g. from a temporary CVS checkout located at
.Pa /tmp/src :
.Pp
-.Dl $ gotadmin init /var/git/src.git
+.Dl $ got init /var/git/src.git
.Dl $ got import -r /var/git/src.git -I CVS -I obj /tmp/src
.Pp
Check out a work tree from the Git repository to /usr/src:
blob - d516b6ee8445681a1f22e237b7601a2852a9b54e
blob + d6b6ac8a4c79908338a851d745e13fbf96c2dac7
--- got/got.c
+++ got/got.c
};
__dead static void usage(int, int);
+__dead static void usage_init(void);
__dead static void usage_import(void);
__dead static void usage_clone(void);
__dead static void usage_fetch(void);
__dead static void usage_cat(void);
__dead static void usage_info(void);
+static const struct got_error* cmd_init(int, char *[]);
static const struct got_error* cmd_import(int, char *[]);
static const struct got_error* cmd_clone(int, char *[]);
static const struct got_error* cmd_fetch(int, char *[]);
static const struct got_error* cmd_info(int, char *[]);
static const struct got_cmd got_commands[] = {
+ { "init", cmd_init, usage_init, "" },
{ "import", cmd_import, usage_import, "im" },
{ "clone", cmd_clone, usage_clone, "cl" },
{ "fetch", cmd_fetch, usage_fetch, "fe" },
}
__dead static void
+usage_init(void)
+{
+ fprintf(stderr, "usage: %s init [-b branch] repository-path\n",
+ getprogname());
+ exit(1);
+}
+
+static const struct got_error *
+cmd_init(int argc, char *argv[])
+{
+ const struct got_error *error = NULL;
+ const char *head_name = NULL;
+ char *repo_path = NULL;
+ int ch;
+
+ while ((ch = getopt(argc, argv, "b:")) != -1) {
+ switch (ch) {
+ case 'b':
+ head_name = optarg;
+ break;
+ default:
+ usage_init();
+ /* NOTREACHED */
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+#ifndef PROFILE
+ if (pledge("stdio rpath wpath cpath unveil", NULL) == -1)
+ err(1, "pledge");
+#endif
+ if (argc != 1)
+ usage_init();
+
+ repo_path = strdup(argv[0]);
+ if (repo_path == NULL)
+ return got_error_from_errno("strdup");
+
+ got_path_strip_trailing_slashes(repo_path);
+
+ error = got_path_mkdir(repo_path);
+ if (error &&
+ !(error->code == GOT_ERR_ERRNO && errno == EEXIST))
+ goto done;
+
+ error = apply_unveil(repo_path, 0, NULL);
+ if (error)
+ goto done;
+
+ error = got_repo_init(repo_path, head_name);
+done:
+ free(repo_path);
+ return error;
+}
+
+__dead static void
usage_import(void)
{
fprintf(stderr, "usage: %s import [-b branch] [-I pattern] [-m message] "
blob - dde785d1cee7ca7d6591b4aeae5dc65472294bc7
blob + 00bb07ed7939d88c75f1fb6e94a7b77a86d50730
--- gotadmin/gotadmin.1
+++ gotadmin/gotadmin.1
.Pp
After
.Cm gotadmin init ,
-the
-.Cm got import
-command must be used to populate the empty repository before
+the new repository must be populated before
.Cm got checkout
can be used.
+The
+.Cm got import
+command can be used to populate the new repository with data from
+a local directory.
+Alternatively, on a server running
+.Xr gotd 8 ,
+the new repository can be made available to
+.Xr got 1
+or
+.Xr git 1
+clients by adding the repository to
+.Xr gotd.conf 5
+and restarting
+.Xr gotd 8 .
+Clients may then clone the new repository from the server, populate the cloned
+repository, and then populate the new repository on the server via
+.Cm got send
+or
+.Cm git push .
.Pp
The options for
.Cm gotadmin init
instead of the default branch
.Dq main .
.El
+.Pp
+The
+.Cm gotadmin init
+command is equivalent to
+.Cm got init .
.It Cm info Op Fl r Ar repository-path
Display information about a repository.
This includes some configuration settings from
blob - 3deea57b8d4424f745a81ebe3900dbf4632bd8d7
blob + 641a80e0f4d3a3e6c42194d00008d26feca19ae0
--- regress/cmdline/import.sh
+++ regress/cmdline/import.sh
local testroot=`mktemp -d \
"$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
- gotadmin init $testroot/repo
+ got init $testroot/repo
mkdir $testroot/tree
make_test_tree $testroot/tree
local testroot=`mktemp -d \
"$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
- gotadmin init $testroot/repo
+ got init $testroot/repo
mkdir $testroot/tree
make_test_tree $testroot/tree
blob - 2f9468695f6cf968b15297cfe13f3ecee0544e73
blob + d8eb96bab4f0e3966cb1fb48167fcf1be88c38f7
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
git_commit $testroot/repo -m "adding the test tree"
local head_commit=`git_show_head $testroot/repo`
- gotadmin init $testroot/other-repo
+ got init $testroot/other-repo
mkdir -p $testroot/tree
make_test_tree $testroot/tree
got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null