Commit Diff


commit - b7eff1274c82d60d1eeca924bb9c5dcb951a781c
commit + cfbfa60cc722e92165914178267754f432b46ccb
blob - 13fcc34f3da5081d4ae416da9ea13f440d64b1e9
blob + dd78162413eb39225652910fde36f8fd08043467
--- gotadmin/gotadmin.1
+++ gotadmin/gotadmin.1
@@ -387,32 +387,38 @@ be excluded.
 .El
 .It Xo
 .Cm load
-.Op Fl lnq
-.Op Fl b Ar reference
+.Op Fl nq
+.Op Fl l Ar bundle-path
 .Op Fl r Ar repository-path
-.Op Ar file
+.Op Ar reference ...
 .Xc
-Read a Git bundle stream from standard input or
-.Ar file .
+Read a Git bundle stream from standard input and load its data into
+a repository.
 .Pp
+If one or more
+.Ar reference
+arguments are provided then only load the specified references
+from the bundle.
+Otherwise, all references will be loaded.
+.Pp
 The options for
 .Cm gotadmin load
 are as follows:
 .Bl -tag -width Ds
-.It Fl b Ar reference
-Load only the specified
+.It Fl l Ar bundle-path
+List references available for loading from the bundle at the specified
+.Ar bundle-path
+and exit immediately.
+If the
+.Fl l
+option is specified then no
 .Ar reference
-from the bundle.
-This option may be specified multiple times to build a list of
-reference to load.
-If not provided, all the reference will be loaded.
-.It Fl l
-List references available for loading from the bundle and exit
-immediately.
-Cannot be used together with
-.Fl b
-and
-.Fl n .
+arguments are allowed.
+The
+.Fl l
+option is incompatible with the
+.Fl n
+option.
 .It Fl n
 Attempt to load the bundle but don't install new packfile or update any
 reference.
blob - 3ad3883d7f96133dfd8aae99d2140026cdc5141b
blob + 6a1990e9ed9ab7446753f40e6d36eeae5ef24647
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
@@ -1550,8 +1550,8 @@ cmd_dump(int argc, char *argv[])
 __dead static void
 usage_load(void)
 {
-	fprintf(stderr, "usage: %s load [-lnq] [-b reference] "
-	    "[-r repository-path] [file]\n",
+	fprintf(stderr, "usage: %s load [-nq] [-l bundle-file] "
+	    "[-r repository-path] [reference ...]\n",
 	    getprogname());
 	exit(1);
 }
@@ -1683,7 +1683,7 @@ cmd_load(int argc, char *argv[])
 	int list_refs_only = 0;
 	int noop = 0;
 	int verbosity = 0;
-	int ch;
+	int ch, i;
 
 	TAILQ_INIT(&include_args);
 	TAILQ_INIT(&available_refs);
@@ -1694,16 +1694,13 @@ cmd_load(int argc, char *argv[])
 		err(1, "pledge");
 #endif
 
-	while ((ch = getopt(argc, argv, "b:lnqr:")) != -1) {
+	while ((ch = getopt(argc, argv, "l:nqr:")) != -1) {
 		switch (ch) {
-		case 'b':
-			error = got_pathlist_append(&include_args,
-			    optarg, NULL);
-			if (error)
-				return error;
-			break;
 		case 'l':
 			list_refs_only = 1;
+			in = fopen(optarg, "re");
+			if (in == NULL)
+				return got_error_from_errno2("open", optarg);
 			break;
 		case 'n':
 			noop = 1;
@@ -1726,18 +1723,19 @@ cmd_load(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
-	if (list_refs_only && !TAILQ_EMPTY(&include_args))
-		errx(1, "-b and -l are mutually exclusive");
-
+	if (list_refs_only && argc > 1)
+		errx(1, "-l and references on the command line are exclusive");
 	if (list_refs_only && noop)
 		errx(1, "-n and -l are mutually exclusive");
 
-	if (argc > 1)
-		usage_load();
-	if (argc == 1) {
-		in = fopen(argv[0], "re");
-		if (in == NULL)
-			return got_error_from_errno2("open", argv[0]);
+	for (i = 0; i < argc; i++) {
+		char *refname = argv[i];
+		got_path_strip_trailing_slashes(refname);
+		if (!got_ref_name_is_valid(refname))
+			errx(1, "invalid reference name %s", refname);
+		error = got_pathlist_append(&include_args, refname, NULL);
+		if (error)
+			goto done;
 	}
 
 	if (repo_path == NULL) {
blob - 7b7bbe844754e7af7ee9a6c3e88f168a902dbafe
blob + 70bf269325f1dc66d6be29ef5f6b010108cfb01a
--- regress/cmdline/load.sh
+++ regress/cmdline/load.sh
@@ -24,7 +24,7 @@ test_load_bundle() {
 
 	# then load it in an empty repository
 	(cd "$testroot/" && gotadmin init -b master repo2) >/dev/null
-	(cd "$testroot/repo2" && gotadmin load "$testroot/bundle") \
+	(cd "$testroot/repo2" && gotadmin load < "$testroot/bundle") \
 		>/dev/null
 	if [ $? -ne 0 ]; then
 		echo "failed to load the bundle" >&2
@@ -48,7 +48,7 @@ test_load_bundle() {
 	(cd "$testroot/repo" && git bundle create -q \
 		"$testroot/bundle" "$base..master")
 
-	(cd "$testroot/repo2" && gotadmin load "$testroot/bundle") >/dev/null
+	(cd "$testroot/repo2" && gotadmin load < "$testroot/bundle") >/dev/null
 	if [ $? -ne 0 ]; then
 		echo "failed to load incremental bundle" >&2
 		test_done "$testroot" 1
@@ -102,7 +102,7 @@ EOF
 		return 1
 	fi
 
-	(cd "$testroot/repo2" && gotadmin load -q -b refs/heads/newbranch \
+	(cd "$testroot/repo2" && gotadmin load -q refs/heads/newbranch \
 		<$testroot/bundle)
 	if [ $? -ne 0 ]; then
 		echo "gotadmin load failed unexpectedly" >&2