@@ -19,7 +19,7 @@ def test_init_repo_object(self, path_to_dir):
19
19
20
20
from git import Repo
21
21
22
- repo = Repo .init (path_to_dir ) # git init path/to/dir
22
+ repo = Repo .init (path_to_dir )
23
23
# ![1-test_init_repo_object]
24
24
25
25
# [2-test_init_repo_object]
@@ -111,10 +111,43 @@ def test_cloned_repo_object(self, local_dir):
111
111
for d in diffs :
112
112
print (d .a_path )
113
113
114
+ # Output
114
115
# Downloads/file3.txt
115
- # file4.txt
116
116
# ![11-test_cloned_repo_object]
117
117
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
+
118
151
'''Trees and Blobs'''
119
152
120
153
# Latest commit tree
@@ -141,7 +174,7 @@ def test_cloned_repo_object(self, local_dir):
141
174
# ![14-test_cloned_repo_object]
142
175
143
176
# [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 ]
145
178
files_and_dirs
146
179
147
180
# Output
0 commit comments