@@ -19,7 +19,7 @@ def test_init_repo_object(self, path_to_dir):
1919
2020 from git import Repo
2121
22- repo = Repo .init (path_to_dir ) # git init path/to/dir
22+ repo = Repo .init (path_to_dir )
2323 # ![1-test_init_repo_object]
2424
2525 # [2-test_init_repo_object]
@@ -111,10 +111,43 @@ def test_cloned_repo_object(self, local_dir):
111111 for d in diffs :
112112 print (d .a_path )
113113
114+ # Output
114115 # Downloads/file3.txt
115- # file4.txt
116116 # ![11-test_cloned_repo_object]
117117
118+ # compares staging area to head commit
119+ # [11.1-test_cloned_repo_object]
120+ diffs = repo .index .diff (repo .head .commit )
121+ for d in diffs :
122+ print (d .a_path )
123+
124+ # Output
125+
126+ # ![11.1-test_cloned_repo_object]
127+ # [11.2-test_cloned_repo_object]
128+ # lets add untracked.txt
129+ repo .index .add (['untracked.txt' ])
130+ diffs = repo .index .diff (repo .head .commit )
131+ for d in diffs :
132+ print (d .a_path )
133+
134+ # Output
135+ # untracked.txt
136+ # ![11.2-test_cloned_repo_object]
137+
138+ # Compare commit to commit
139+ # [11.3-test_cloned_repo_object]
140+ first_commit = [c for c in repo .iter_commits (all = True )][- 1 ]
141+ diffs = repo .head .commit .diff (first_commit )
142+ for d in diffs :
143+ print (d .a_path )
144+
145+ # Output
146+ # dir1/file2.txt
147+ # ![11.3-test_cloned_repo_object]
148+
149+
150+
118151 '''Trees and Blobs'''
119152
120153 # Latest commit tree
@@ -141,7 +174,7 @@ def test_cloned_repo_object(self, local_dir):
141174 # ![14-test_cloned_repo_object]
142175
143176 # [14.1-test_cloned_repo_object]
144- files_and_dirs = [(entry , entry .name ) for entry in tree ]
177+ files_and_dirs = [(entry , entry .name , entry . type ) for entry in tree ]
145178 files_and_dirs
146179
147180 # Output
0 commit comments