fix 'got send' with tree objects which contain symlinks; reported by Omar
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
diff --git a/lib/pack_create.c b/lib/pack_create.c
index 6f64f97..edaba05 100644
--- a/lib/pack_create.c
+++ b/lib/pack_create.c
@@ -372,8 +372,7 @@ load_tree_entries(struct got_object_id_queue *ids, struct got_pack_metavec *v,
break;
}
- if (got_object_tree_entry_is_symlink(e) ||
- got_object_tree_entry_is_submodule(e) ||
+ if (got_object_tree_entry_is_submodule(e) ||
got_object_idset_contains(idset, id))
continue;
@@ -389,7 +388,7 @@ load_tree_entries(struct got_object_id_queue *ids, struct got_pack_metavec *v,
if (err)
break;
STAILQ_INSERT_TAIL(ids, qid, entry);
- } else if (S_ISREG(mode)) {
+ } else if (S_ISREG(mode) || S_ISLNK(mode)) {
err = add_meta(v, idset, id, p, GOT_OBJ_TYPE_BLOB,
mtime, loose_obj_only, repo);
if (err)
diff --git a/regress/cmdline/send.sh b/regress/cmdline/send.sh
index 5fdd09a..bf73786 100755
--- a/regress/cmdline/send.sh
+++ b/regress/cmdline/send.sh
@@ -40,6 +40,10 @@ EOF
| tr -d ' ' | cut -d: -f2`
echo "modified alpha" > $testroot/repo/alpha
+ (cd $testroot/repo && git rm -q beta)
+ (cd $testroot/repo && ln -s epsilon/zeta symlink && git add symlink)
+ echo "new file alpha" > $testroot/repo/new
+ (cd $testroot/repo && git add new)
git_commit $testroot/repo -m "modified alpha"
local commit_id2=`git_show_head $testroot/repo`
@@ -103,6 +107,18 @@ EOF
return 1
fi
+ got tree -r $testroot/repo-clone -c $commit_id2 -i -R \
+ > $testroot/stdout
+ got tree -r $testroot/repo -c $commit_id2 -i -R \
+ > $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 send -r $testroot/repo > $testroot/stdout 2> $testroot/stderr
ret="$?"
if [ "$ret" != "0" ]; then