Commit Diff


commit - 1f46d0af752f3e60c6ed712b8120328af9d4cd9a
commit + 5cc266baadfb13464b72e1ccbec0462eb641f0b6
blob - b9ce3065d3643e84bd1463d6f6a538314843ce51
blob + 68c4f29cd8883e493adf2db836518b1f1a28d4af
--- lib/worktree.c
+++ lib/worktree.c
@@ -798,9 +798,7 @@ remove_missing_files(struct got_worktree *worktree, co
 	a.fileindex = fileindex;
 	a.entries = entries;
 	a.missing_entries.nentries = 0;
-	a.current_subdir = path;
-	while (a.current_subdir[0] == '/')
-		a.current_subdir++;
+	a.current_subdir = apply_path_prefix(worktree, path);
 	TAILQ_INIT(&a.missing_entries.entries);
 	err = got_fileindex_for_each_entry(fileindex, collect_missing_file, &a);
 	if (err)
blob - cc23e638e0aa3f1fd81b5d6f7aae10193faec62f
blob + 7364849afe9592a0b3c6d21c87ce8042a3a7d498
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
@@ -190,7 +190,54 @@ function test_update_deletes_dir {
 	test_done "$testroot" "$ret"
 }
 
+function test_update_deletes_dir_with_path_prefix {
+	local testroot=`test_init update_deletes_dir_with_path_prefix`
+	local first_rev=`git_show_head $testroot/repo`
+
+	mkdir $testroot/repo/epsilon/psi
+	echo mu > $testroot/repo/epsilon/psi/mu
+	(cd $testroot/repo && git add .)
+	git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
+
+	# check out the epsilon/ sub-tree
+	got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
+	if [ "$?" != "0" ]; then
+		test_done "$testroot" "$?"
+		return 1
+	fi
+
+	# update back to first commit and expect psi/mu to be deleted
+	echo "D  psi/mu" > $testroot/stdout.expected
+	echo "Updated to commit $first_rev" >> $testroot/stdout.expected
+
+	(cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
+
+	cmp $testroot/stdout.expected $testroot/stdout
+	if [ "$?" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$?"
+		return 1
+	fi
+
+	if [ -e $testroot/wt/psi ]; then
+		echo "removed dir psi still exists on disk" >&2
+		test_done "$testroot" "1"
+		return 1
+	fi
+
+	echo "zeta" >> $testroot/content.expected
+	cat $testroot/wt/zeta > $testroot/content
+
+	cmp $testroot/content.expected $testroot/content
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/content.expected $testroot/content
+	fi
+	test_done "$testroot" "$ret"
+}
+
 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