commit - 25a58941e2beadb3c782e68c751bd74947177955
commit + 81a30460ae72c2e83fd47df22f93785661b7b750
blob - 408e0bd8f8d26ff2e25ef7ee4e2a7533ae792ba6
blob + ff90b0e46ae236d0a572b6bf0c149df9bdfb55b4
--- lib/worktree.c
+++ lib/worktree.c
return NULL;
start = entry->path + strlen(a->current_subdir);
+ if (a->current_subdir[0] != '\0' && start[0] != '/')
+ return NULL;
while (start[0] == '/')
start++;
end = strchr(start, '/');
blob - eb351e57fada625d5e0502ffd0f5e3a0b7065c4b
blob + 2faad6b33219ecb7ececbd17d7357f660bd523bd
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
test_done "$testroot" "0"
}
+function test_update_with_sibling_dirs_with_common_prefix {
+ local testroot=`test_init update_with_sibling_dirs_with_common_prefix`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ if [ "$?" != "0" ]; then
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ mkdir $testroot/repo/epsilon2
+ echo mu > $testroot/repo/epsilon2/mu
+ (cd $testroot/repo && git add epsilon2/mu)
+ git_commit $testroot/repo -m "adding sibling of epsilon"
+ echo change > $testroot/repo/epsilon/zeta
+ git_commit $testroot/repo -m "changing epsilon/zeta"
+
+ echo "U epsilon/zeta" > $testroot/stdout.expected
+ echo "A epsilon2/mu" >> $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp $testroot/stdout.expected $testroot/stdout
+ if [ "$?" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ echo "another change" > $testroot/repo/epsilon/zeta
+ git_commit $testroot/repo -m "changing epsilon/zeta again"
+
+ echo "U epsilon/zeta" > $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ # Bug: This update used to do delete/add epsilon2/mu again:
+ # U epsilon/zeta
+ # D epsilon2/mu <--- not intended
+ # A epsilon2/mu <--- not intended
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp $testroot/stdout.expected $testroot/stdout
+ if [ "$?" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ cmp $testroot/stdout.expected $testroot/stdout
+ if [ "$?" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ test_done "$testroot" "0"
+}
+
run_test test_update_basic
run_test test_update_adds_file
run_test test_update_deletes_file
run_test test_update_deletes_dir
run_test test_update_deletes_dir_with_path_prefix
run_test test_update_deletes_dir_recursively
+run_test test_update_with_sibling_dirs_with_common_prefix