commit c2105d002a73e60c6f3194dd96a1a0b09eb34e08 from: Stefan Sperling date: Tue Sep 14 19:02:10 2021 UTC fix another instance of 'got send' sending branches the server already has commit - 13364f2d81ad613f67036d34a5181ff1cb1ecf3c commit + c2105d002a73e60c6f3194dd96a1a0b09eb34e08 blob - 389638ce5e6ef123646ace201dde42a8e1706e20 blob + 439105b666bbf6eb9e40bf4c2cfa6b3c25e52eeb --- lib/send.c +++ lib/send.c @@ -330,7 +330,6 @@ got_send_pack(const char *remote_name, struct got_path struct got_reflist_entry *re; struct got_object_id **our_ids = NULL; struct got_object_id **their_ids = NULL; - struct got_object_id *my_id = NULL; int i, nours = 0, ntheirs = 0; size_t nalloc_ours = 0, nalloc_theirs = 0; int refs_to_send = 0, refs_to_delete = 0; @@ -518,15 +517,13 @@ got_send_pack(const char *remote_name, struct got_path */ my_ref = find_ref(&refs, refname); if (my_ref) { + struct got_object_id *my_id; err = got_ref_resolve(&my_id, repo, my_ref); if (err) goto done; - if (got_object_id_cmp(my_id, their_id) == 0) { - free(my_id); - my_id = NULL; - continue; - } - refs_to_send++; + if (got_object_id_cmp(my_id, their_id) != 0) + refs_to_send++; + free(my_id); } @@ -722,6 +719,5 @@ done: for (i = 0; i < ntheirs; i++) free(their_ids[i]); free(their_ids); - free(my_id); return err; } blob - f0906797fbd245cfac46245cdc9d44795c8e78a1 blob + eb88e75caf53cdb64f76ece8d89df60b00089758 --- regress/cmdline/send.sh +++ regress/cmdline/send.sh @@ -719,8 +719,47 @@ EOF ret="$?" if [ "$ret" != "0" ]; then diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 fi - test_done "$testroot" "$ret" + + got checkout $testroot/repo $testroot/wt > /dev/null + echo 'new line in file alpha' >> $testroot/wt/alpha + (cd $testroot/wt && got commit -m 'changing file alpha' > /dev/null) + + # Send the new commit in isolation. + 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 + + # Now tag it and send the tag. + # Verify that just the new tag object gets sent. + got tag -r $testroot/repo -m '3.0' 3.0 >/dev/null + tag_id4=`got ref -r $testroot/repo -l | grep "^refs/tags/1.0" \ + | tr -d ' ' | cut -d: -f2` + + got send -r $testroot/repo -t 3.0 > $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 + if ! grep -q "packing 2 references; 1 object; deltify: 100%" \ + $testroot/stdout; then + echo "got send did apparently pack too many objects:" >&2 + cat $testroot/stdout.raw >&2 + test_done "$testroot" "1" + return 1 + fi + test_done "$testroot" "0" } test_send_tag_of_deleted_branch() {