Download raw body.
fix send -T regression
Omar reported on IRC that got send -T fails if an existing tag has already been uploaded to the server. This patch adds test coverage for the issue and fixes the bug. The problem was introduced in commit c2105d00. ok? ----------------------------------------------- commit bd9f97dbcebf2b3c435738a600ad3d064bd9ee2c (send-tags) from: Stefan Sperling <stsp@stsp.name> date: Sat Oct 16 14:43:01 2021 UTC fix regression where 'got send -T' failed if same tag already exists on server diff 0aed43d9b22428ff3eaf4b20d7b7df4aaa0bc3cc b680d836ecbe495af809976964413b17f3cb6315 blob - 7250f245c5c0f1d67211774b2cb6c6c571879eec blob + 0576ad42d0f1ba289507bd309c4b24c1bb0f2dbb --- lib/send.c +++ lib/send.c @@ -511,6 +511,8 @@ got_send_pack(const char *remote_name, struct got_path if (!got_ref_name_is_valid(refname)) continue; + if (strncmp(refname, "refs/tags/", 10) == 0) + is_tag = 1; /* * Find out whether this is a reference we want to upload. * Otherwise we can still use this reference as a hint to @@ -522,22 +524,19 @@ got_send_pack(const char *remote_name, struct got_path err = got_ref_resolve(&my_id, repo, my_ref); if (err) goto done; - if (got_object_id_cmp(my_id, their_id) != 0) + if (got_object_id_cmp(my_id, their_id) != 0) { + if (!overwrite_refs && is_tag) { + err = got_error_fmt( + GOT_ERR_SEND_TAG_EXISTS, + "%s", refname); + free(my_id); + goto done; + } refs_to_send++; + } free(my_id); - } - if (strncmp(refname, "refs/tags/", 10) == 0) - is_tag = 1; - - /* Prevent tags from being overwritten by default. */ - if (!overwrite_refs && my_ref && is_tag) { - err = got_error_fmt(GOT_ERR_SEND_TAG_EXISTS, - "%s", refname); - goto done; - } - /* Check if their object exists locally. */ err = got_object_open(&obj, repo, their_id); if (err) { blob - bf7378666fbaffcdef506f93bd3df20d0c8e454b blob + 3eb8e7e29c0385103d644e4f76b51d8f5f478922 --- regress/cmdline/send.sh +++ regress/cmdline/send.sh @@ -687,6 +687,24 @@ EOF return 1 fi + # Send the same tags again. This should be a no-op. + got send -q -r $testroot/repo -T > $testroot/stdout 2> $testroot/stderr + ret="$?" + if [ "$ret" != "0" ]; then + echo "got send command failed unexpectedly" >&2 + test_done "$testroot" "$ret" + return 1 + fi + + echo -n > $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 + # Overwriting an existing tag 'got send -f'. got ref -r $testroot/repo -d refs/tags/1.0 >/dev/null got tag -r $testroot/repo -m '1.0' 1.0 >/dev/null
fix send -T regression