File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
crates/gitbutler-project/src Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,17 @@ impl Project {
120120 }
121121 /// Finds an existing project by its path. Errors out if not found.
122122 pub fn find_by_path ( path : & Path ) -> anyhow:: Result < Project > {
123- let projects = crate :: list ( ) ?;
123+ let mut projects = crate :: list ( ) ?;
124+ // Sort projects by longest pathname to shortest.
125+ // We need to do this because users might have one gitbutler project
126+ // nexted insided of another via a gitignored folder.
127+ // We want to match on the longest project path.
128+ projects. sort_by ( |a, b| {
129+ b. path
130+ . to_string_lossy ( )
131+ . len ( )
132+ . cmp ( & a. path . to_string_lossy ( ) . len ( ) )
133+ } ) ;
124134 let resolved_path = if path. is_relative ( ) {
125135 path. canonicalize ( ) . context ( "Failed to canonicalize path" ) ?
126136 } else {
You can’t perform that action at this time.
0 commit comments