Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
set: -n never matches the first argument vs origin anymore
Baptiste Daroussin committed 1 month ago
commit 501f6d88d41aec5f5f5e631f5324e45c069cb184
parent a376ade
2 files changed +29 -1
modified src/set.c
@@ -290,7 +290,8 @@ exec_set(int argc, char **argv)

	if (oldvalue != NULL) {
		match = MATCH_ALL;
-
		if ((it = pkgdb_query(db, oldvalue, MATCH_EXACT)) == NULL) {
+
		if ((it = pkgdb_query(db, oldvalue,
+
		    (sets & NAME) ? MATCH_INTERNAL : MATCH_EXACT)) == NULL) {
			retcode = EXIT_FAILURE;
			goto cleanup;
		}
modified tests/frontend/set.sh
@@ -6,6 +6,7 @@ tests_init \
	set_automatic \
	set_change_name \
	set_change_origin \
+
	set_change_name_not_origin \
	set_vital \
	set_partial

@@ -87,6 +88,32 @@ set_change_origin_body() {
		pkg info -qo
}

+
set_change_name_not_origin_body() {
+
	initialize_pkg
+

+
	# pkg set -n should match by name only, not by origin (issue #1187).
+
	# "origin/test" contains a slash and matches the origin, but -n
+
	# must not find the package through its origin and rename it.
+
	atf_check \
+
		-s exit:0 \
+
		pkg set -yn origin/test:newname
+

+
	# Verify the package name and origin are unchanged:
+
	# Before the fix, the name would become "newname" because -n
+
	# matched via origin instead of name.
+
	atf_check \
+
		-o inline:"test-1\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -q
+

+
	atf_check \
+
		-o inline:"origin/test\n" \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -qo
+
}
+

set_vital_body() {
	initialize_pkg