commit - dfe70b4b0a1ad22cb3da16a487106f0a14be3c5f
commit + 6aeab5968f2b14a7aaff1360ae8f6a1679626ecb
blob - c4723d5692b318f338242ac11195e9f2a00f13a9
blob + c175b73a7f6b103afe3ff4d34260aae5be101cfc
--- lib/reference.c
+++ lib/reference.c
{
const struct got_error *err;
char *packed_refs_path, *path_refs = NULL;
+ const char *ondisk_ref_namespace = NULL;
FILE *f = NULL;
struct got_reference *ref;
struct got_reflist_entry *new;
goto done;
}
+ ondisk_ref_namespace = ref_namespace;
if (ref_namespace && strncmp(ref_namespace, "refs/", 5) == 0)
- ref_namespace += 5;
+ ondisk_ref_namespace += 5;
/* Gather on-disk refs before parsing packed-refs. */
free(path_refs);
goto done;
}
err = gather_on_disk_refs(refs, path_refs,
- ref_namespace ? ref_namespace : "", repo, cmp_cb, cmp_arg);
+ ondisk_ref_namespace ? ondisk_ref_namespace : "", repo,
+ cmp_cb, cmp_arg);
if (err)
goto done;
blob - 3b0f39ae7466ebc08e2f0615d9193dbfb8b84ba8
blob + 1b883c4e2688ea9c09323b246a34eeedd90657cb
--- regress/cmdline/branch.sh
+++ regress/cmdline/branch.sh
return 1
fi
+ got ref -l -r $testroot/repo > $testroot/stdout
+ echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+ echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
+ echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
+ echo "refs/heads/master: $commit_id" >> $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 branch -d bogus_branch_name -r $testroot/repo \
> $testroot/stdout 2> $testroot/stderr
ret="$?"
test_done "$testroot" "$ret"
}
+function test_branch_delete_packed {
+ local testroot=`test_init branch_delete_packed`
+ local commit_id=`git_show_head $testroot/repo`
+
+ for b in branch1 branch2 branch3; do
+ got branch -r $testroot/repo $b
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "got branch command failed unexpectedly"
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ done
+
+ (cd $testroot/repo && git pack-refs --all)
+
+ got branch -d branch2 -r $testroot/repo > $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "got update command failed unexpectedly"
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got branch -l -r $testroot/repo > $testroot/stdout
+ echo " branch1: $commit_id" > $testroot/stdout.expected
+ echo " branch3: $commit_id" >> $testroot/stdout.expected
+ echo " master: $commit_id" >> $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 ref -l -r $testroot/repo > $testroot/stdout
+ echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+ echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
+ echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
+ echo "refs/heads/master: $commit_id" >> $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 branch -d bogus_branch_name -r $testroot/repo \
+ > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "got update succeeded unexpectedly"
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "got: reference refs/heads/bogus_branch_name not found" \
+ > $testroot/stderr.expected
+ cmp -s $testroot/stderr $testroot/stderr.expected
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ fi
+ test_done "$testroot" "$ret"
+}
+
run_test test_branch_create
run_test test_branch_list
run_test test_branch_delete
run_test test_branch_delete_current_branch
+run_test test_branch_delete_packed