@@ -1218,14 +1218,29 @@ def test_index_add_non_normalized_path(self, rw_repo):
12181218
12191219rw_repo .index .add (non_normalized_path )
12201220
1221+ def test_index_file_v3 (self ):
1222+ index = IndexFile (self .rorepo ,fixture_path ("index_extended_flags" ))
1223+ assert index .entries
1224+ assert index .version == 3
1225+ assert len (index .entries )== 4
1226+ assert index .entries [('init.t' ,0 )].skip_worktree
1227+
1228+ # Write the data - it must match the original.
1229+ tmpfile = tempfile .mktemp ()
1230+ index .write (tmpfile )
1231+ assert Path (tmpfile ).read_bytes ()== Path (fixture_path ("index_extended_flags" )).read_bytes ()
1232+ os .remove (tmpfile )
1233+
12211234@with_rw_directory
1222- def test_index_version_v3 (self ,tmp_dir ):
1235+ def test_index_file_v3_with_git_command (self ,tmp_dir ):
12231236tmp_dir = Path (tmp_dir )
12241237with cwd (tmp_dir ):
1225- subprocess .run (["git" ,"init" ,"-q" ],check = True )
1238+ git = Git (tmp_dir )
1239+ git .init ()
1240+
12261241file = tmp_dir / "file.txt"
12271242file .write_text ("hello" )
1228- subprocess . run ([ "git" , " add" ,"-N" , " file.txt"], check = True )
1243+ git . add ( "--intent-to- add" ,"file.txt" ) # intent-to-add sets extended flag
12291244
12301245repo = Repo (tmp_dir )
12311246
@@ -1239,9 +1254,10 @@ def test_index_version_v3(self, tmp_dir):
12391254repo .index .add (["file2.txt" ])
12401255repo .index .write ()
12411256
1242- status_str = subprocess .check_output (["git" ,"status" ,"--porcelain" ],text = True )
1243- assert " A file.txt\n " in status_str
1244- assert "A file2.txt\n " in status_str
1257+ status_str = git .status (porcelain = True )
1258+ status_lines = status_str .splitlines ()
1259+ assert " A file.txt" in status_lines
1260+ assert "A file2.txt" in status_lines
12451261
12461262
12471263class TestIndexUtils :