"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
got send got.conf fix
To:
gameoftrees@openbsd.org
Date:
Tue, 31 Aug 2021 10:17:53 +0200

Download raw body.

Thread
  • Stefan Sperling:

    got send got.conf fix

Make 'got send' heed the branch {} options in got.conf(5) as intended.

ok?

diff e0f2ce4d7ce9164f7b9591a9df7e2d7bf4556308 cfdacf0ef78a17b28543abbbb6927b424f1b1949
blob - 1edb356b8da783560a7d0691d12708ca5376fb29
blob + 51bedeed3942da484d0dfe4614307f848dcbd5ed
--- got/got.c
+++ got/got.c
@@ -7751,6 +7751,11 @@ cmd_send(int argc, char *argv[])
 				goto done;
 			nbranches++;
 		}
+	} else if (nbranches == 0) {
+		for (i = 0; i < remote->nsend_branches; i++) {
+			got_pathlist_append(&branches,
+			    remote->send_branches[i], NULL);
+		}
 	}
 
 	if (send_all_tags) {
blob - 2c2112b0a45b7a3317cd276452aa270633f87995
blob + ce7b085beed403260f19800f8e25f6d484e5e1d5
--- regress/cmdline/send.sh
+++ regress/cmdline/send.sh
@@ -1158,6 +1158,82 @@ EOF
 	test_done "$testroot" "$ret"
 }
 
+test_send_config() {
+	local testroot=`test_init send_fetch_conf`
+	local testurl=ssh://127.0.0.1/$testroot
+	local commit_id=`git_show_head $testroot/repo`
+
+	got clone -q $testurl/repo $testroot/repo-clone
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		echo "got clone command failed unexpectedly" >&2
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	cat > $testroot/repo/.git/got.conf <<EOF
+remote "origin" {
+	protocol ssh
+	server 127.0.0.1
+	branch foo
+	repository "$testroot/repo-clone"
+}
+EOF
+	got ref -l -r $testroot/repo-clone > $testroot/stdout
+	if [ "$ret" != "0" ]; then
+		echo "got ref command failed unexpectedly" >&2
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+	echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
+	echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
+		>> $testroot/stdout.expected
+	echo "refs/remotes/origin/master: $commit_id" \
+		>> $testroot/stdout.expected
+
+	cmp -s $testroot/stdout $testroot/stdout.expected
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+	
+	got branch -r $testroot/repo foo
+
+	got send -q -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		echo "got send command failed unexpectedly" >&2
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	got ref -l -r $testroot/repo-clone > $testroot/stdout
+	if [ "$ret" != "0" ]; then
+		echo "got ref command failed unexpectedly" >&2
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+	echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
+	echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
+	echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
+		>> $testroot/stdout.expected
+	echo "refs/remotes/origin/master: $commit_id" \
+		>> $testroot/stdout.expected
+
+	cmp -s $testroot/stdout $testroot/stdout.expected
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
+	test_done "$testroot" "$ret"
+}
+
 test_parseargs "$@"
 run_test test_send_basic
 run_test test_send_rebase_required
@@ -1169,3 +1245,4 @@ run_test test_send_new_branch
 run_test test_send_all_branches
 run_test test_send_to_empty_repo
 run_test test_send_and_fetch_config
+run_test test_send_config