File tree 4 files changed +51
-4
lines changed
4 files changed +51
-4
lines changed Original file line number Diff line number Diff line change @@ -263,11 +263,21 @@ impl ThreadSafeRepository {
263
263
. resolved
264
264
. path_filter ( Core :: WORKTREE , {
265
265
|section| {
266
- let res = filter_config_section ( section) ;
267
- if res {
268
- key_source = Some ( section. source ) ;
266
+ if !filter_config_section ( section) {
267
+ return false ;
269
268
}
270
- res
269
+ // ignore worktree settings that aren't from our repository. This can happen
270
+ // with worktrees of submodules for instance.
271
+ let is_config_in_our_repo = section
272
+ . path
273
+ . as_deref ( )
274
+ . and_then ( |p| gix_path:: normalize ( p. into ( ) , current_dir) )
275
+ . is_some_and ( |config_path| config_path. starts_with ( & git_dir) ) ;
276
+ if !is_config_in_our_repo {
277
+ return false ;
278
+ }
279
+ key_source = Some ( section. source ) ;
280
+ true
271
281
}
272
282
} )
273
283
. zip ( key_source) ;
Original file line number Diff line number Diff line change 7
7
/make_core_worktree_repo.tar
8
8
/make_signatures_repo.tar
9
9
/make_diff_repos.tar
10
+ /make_submodule_with_worktree.tar
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -eu -o pipefail
3
+
4
+ git init -q module1
5
+ (cd module1
6
+ touch this
7
+ git add . && git commit -q -m c1
8
+ )
9
+
10
+ git init submodule-with-extra-worktree-host
11
+ (cd submodule-with-extra-worktree-host
12
+ git submodule add ../module1 m1
13
+ (cd m1
14
+ git worktree add ../../worktree-of-submodule
15
+ )
16
+ )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ mod open {
11
11
use gix:: submodule;
12
12
13
13
use crate :: submodule:: repo;
14
+ use crate :: util:: named_subrepo_opts;
14
15
15
16
#[ test]
16
17
fn various ( ) -> crate :: Result {
@@ -341,6 +342,25 @@ mod open {
341
342
Ok ( ( ) )
342
343
}
343
344
345
+ #[ test]
346
+ fn submodule_worktrees ( ) -> crate :: Result {
347
+ let sm_repo = named_subrepo_opts (
348
+ "make_submodule_with_worktree.sh" ,
349
+ "worktree-of-submodule" ,
350
+ gix:: open:: Options :: isolated ( ) ,
351
+ ) ?;
352
+ let wd = sm_repo. work_dir ( ) . expect ( "workdir is present" ) ;
353
+ assert ! (
354
+ sm_repo. rev_parse_single( ":this" ) . is_ok( ) ,
355
+ "the file is in the submodule"
356
+ ) ;
357
+ assert ! (
358
+ wd. join( "this" ) . is_file( ) ,
359
+ "The submodule itself has the file, so it should be in the worktree"
360
+ ) ;
361
+ Ok ( ( ) )
362
+ }
363
+
344
364
#[ test]
345
365
fn old_form ( ) -> crate :: Result {
346
366
for name in [ "old-form-invalid-worktree-path" , "old-form" ] {
You can’t perform that action at this time.
0 commit comments