1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 06:47:52 +01:00
git/t/t1407-worktree-ref-store.sh
Nguyễn Thái Ngọc Duy d026a25657 refs: kill set_worktree_head_symref()
70999e9cec (branch -m: update all per-worktree HEADs - 2016-03-27)
added this function in order to update HEADs of all relevant
worktrees, when a branch is renamed.

It, as a public ref api, kind of breaks abstraction when it uses
internal functions of files backend. With the introduction of
refs_create_symref(), we can move back pretty close to the code before
70999e9cec, where create_symref() was used for updating HEAD.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-24 21:28:55 -07:00

52 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
test_description='test worktree ref store api'
. ./test-lib.sh
RWT="test-ref-store worktree:wt"
RMAIN="test-ref-store worktree:main"
test_expect_success 'setup' '
test_commit first &&
git worktree add -b wt-master wt &&
(
cd wt &&
test_commit second
)
'
test_expect_success 'resolve_ref(<shared-ref>)' '
SHA1=`git rev-parse master` &&
echo "$SHA1 refs/heads/master 0x0" >expected &&
$RWT resolve-ref refs/heads/master 0 >actual &&
test_cmp expected actual &&
$RMAIN resolve-ref refs/heads/master 0 >actual &&
test_cmp expected actual
'
test_expect_success 'resolve_ref(<per-worktree-ref>)' '
SHA1=`git -C wt rev-parse HEAD` &&
echo "$SHA1 refs/heads/wt-master 0x1" >expected &&
$RWT resolve-ref HEAD 0 >actual &&
test_cmp expected actual &&
SHA1=`git rev-parse HEAD` &&
echo "$SHA1 refs/heads/master 0x1" >expected &&
$RMAIN resolve-ref HEAD 0 >actual &&
test_cmp expected actual
'
test_expect_success 'create_symref(FOO, refs/heads/master)' '
$RWT create-symref FOO refs/heads/master nothing &&
echo refs/heads/master >expected &&
git -C wt symbolic-ref FOO >actual &&
test_cmp expected actual &&
$RMAIN create-symref FOO refs/heads/wt-master nothing &&
echo refs/heads/wt-master >expected &&
git symbolic-ref FOO >actual &&
test_cmp expected actual
'
test_done