fix another instance of 'got send' sending branches the server already has
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/lib/send.c b/lib/send.c
index 389638c..439105b 100644
--- a/lib/send.c
+++ b/lib/send.c
@@ -330,7 +330,6 @@ got_send_pack(const char *remote_name, struct got_pathlist_head *branch_names,
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_pathlist_head *branch_names,
*/
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;
}
diff --git a/regress/cmdline/send.sh b/regress/cmdline/send.sh
index f090679..eb88e75 100755
--- a/regress/cmdline/send.sh
+++ b/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() {