From 5a7d8ac596f1e7b91e92f5c2204474efaeee0f20 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 24 Jan 2024 12:29:33 +0900 Subject: [PATCH] working_copy: don't follow symlinks when visiting files in gitignored directory Fixes #2878 --- CHANGELOG.md | 3 +++ lib/src/local_working_copy.rs | 2 +- lib/tests/test_local_working_copy.rs | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4106a4c9f..77e07fb7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed bugs +* Fixed snapshots of symlinks in `gitignore`-d directory. + [#2878](https://github.com/martinvonz/jj/issues/2878) + ## [0.13.0] - 2024-01-03 diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 5045dc318..3e351f4cf 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -894,7 +894,7 @@ impl TreeState { continue; } let disk_path = tracked_path.to_fs_path(&self.working_copy_path); - let metadata = match disk_path.metadata() { + let metadata = match disk_path.symlink_metadata() { Ok(metadata) => metadata, Err(err) if err.kind() == std::io::ErrorKind::NotFound => { continue; diff --git a/lib/tests/test_local_working_copy.rs b/lib/tests/test_local_working_copy.rs index 6566ee3b7..fb8253cf6 100644 --- a/lib/tests/test_local_working_copy.rs +++ b/lib/tests/test_local_working_copy.rs @@ -836,9 +836,7 @@ fn test_gitignores_ignored_directory_already_tracked() { (modified_normal_path, Kind::Normal, "modified"), (unchanged_executable_path, Kind::Executable, "contents"), (modified_executable_path, Kind::Executable, "modified"), - #[cfg(not(unix))] // TODO (unchanged_symlink_path, Kind::Symlink, "contents"), - #[cfg(not(unix))] // TODO (modified_symlink_path, Kind::Symlink, "modified"), ]); assert_eq!(