fix the output of 'got send -d' upon success Previous output was: Already up-to-date New output is: Server has deleted refs/heads/branch Check this behavour in the related regression test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/lib/send.c b/lib/send.c
index 52f062e..52892c3 100644
--- a/lib/send.c
+++ b/lib/send.c
@@ -742,6 +742,13 @@ got_send_pack(const char *remote_name, struct got_pathlist_head *branch_names,
refs_to_send++;
}
+ /* Account for any existing references we are going to delete. */
+ TAILQ_FOREACH(pe, delete_branches, entry) {
+ const char *branchname = pe->path;
+ if (find_their_ref(&their_refs, branchname))
+ refs_to_send++;
+ }
+
if (refs_to_send == 0) {
got_privsep_send_stop(imsg_sendfds[0]);
goto done;
diff --git a/regress/cmdline/send.sh b/regress/cmdline/send.sh
index e05bcb5..d8ab1ac 100755
--- a/regress/cmdline/send.sh
+++ b/regress/cmdline/send.sh
@@ -353,14 +353,30 @@ EOF
return 1
fi
- got send -q -r $testroot/repo -d refs/heads/branch2 origin \
- > $testroot/stdout 2> $testroot/stderr
+ got send -r $testroot/repo -d refs/heads/branch2 origin \
+ > $testroot/stdout.raw 2>$testroot/stderr
ret="$?"
if [ "$ret" != "0" ]; then
echo "got send command failed unexpectedly" >&2
test_done "$testroot" "$ret"
return 1
fi
+ tr -d '\r' < $testroot/stdout.raw > $testroot/stdout
+
+ echo 'Connecting to "origin" 127.0.0.1' > $testroot/stdout.expected
+ echo -n "packing 0 references; 0 objects; deltify: 0%; " \
+ >> $testroot/stdout.expected
+ echo "uploading pack: 32B 100%" >> $testroot/stdout.expected
+ echo "Server has deleted refs/heads/branch2" \
+ >> $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
# branchX exists in neither repository
got send -q -r $testroot/repo -d refs/heads/branchX origin \