File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,23 +198,39 @@ def export_files(tree, files):
198198
199199 final = []
200200 for path , fid in files .iteritems ():
201+ kind = tree .kind (fid )
202+
201203 h = tree .get_file_sha1 (fid )
202204
203- mode = '100644'
205+ if kind == 'symlink' :
206+ d = tree .get_symlink_target (fid )
207+ mode = '120000'
208+ elif kind == 'file' :
209+
210+ if tree .is_executable (fid ):
211+ mode = '100755'
212+ else :
213+ mode = '100644'
214+
215+ # is the blog already exported?
216+ if h in filenodes :
217+ mark = filenodes [h ]
218+ final .append ((mode , mark , path ))
219+ continue
204220
205- # is the blob already exported?
206- if h in filenodes :
207- mark = filenodes [h ]
208- else :
209221 d = tree .get_file_text (fid )
222+ elif kind == 'directory' :
223+ continue
224+ else :
225+ die ("Unhandled kind '%s' for path '%s'" % (kind , path ))
210226
211- mark = marks .next_mark ()
212- filenodes [h ] = mark
227+ mark = marks .next_mark ()
228+ filenodes [h ] = mark
213229
214- print "blob"
215- print "mark :%u" % mark
216- print "data %d" % len (d )
217- print d
230+ print "blob"
231+ print "mark :%u" % mark
232+ print "data %d" % len (d )
233+ print d
218234
219235 final .append ((mode , mark , path ))
220236
Original file line number Diff line number Diff line change @@ -108,4 +108,36 @@ test_expect_success 'roundtrip' '
108108 test_cmp expected actual
109109'
110110
111+ cat > expected << EOF
112+ 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
113+ 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
114+ 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
115+ EOF
116+
117+ test_expect_success ' special modes' '
118+ (cd bzrrepo &&
119+ echo exec > executable
120+ chmod +x executable &&
121+ bzr add executable
122+ bzr commit -m exec &&
123+ ln -s content link
124+ bzr add link
125+ bzr commit -m link &&
126+ mkdir dir &&
127+ bzr add dir &&
128+ bzr commit -m dir) &&
129+
130+ (cd gitrepo &&
131+ git pull
132+ git ls-tree HEAD > ../actual) &&
133+
134+ test_cmp expected actual &&
135+
136+ (cd gitrepo &&
137+ git cat-file -p HEAD:link > ../actual) &&
138+
139+ echo -n content > expected &&
140+ test_cmp expected actual
141+ '
142+
111143test_done
You can’t perform that action at this time.
0 commit comments