Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

Merge fix for cloning repositories without HEAD set.

Changeset 25250c1694da

Parents 2bcbc61672e5

Parents 06fbcb6ae8a6

by Jelmer Vernooij

Changes to 3 files · Browse files at 25250c1694da Showing diff from parent 2bcbc61672e5 06fbcb6ae8a6 Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
29
30
31
 
 
 
32
33
34
 
29
30
31
32
33
34
35
36
37
@@ -29,6 +29,9 @@
  the previous one. (Yifan Zhang, issue #59)     * Handle None elements in lists of TreeChange objects. (Alex Holmes) + + * Support cloning repositories without HEAD set. + (D-Key, Jelmer Vernooij, issue #69)    0.8.5 2012-03-29  
Change 1 of 1 Show Entire File dulwich/​repo.py Stacked
 
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
 
 
 
 
 
 
 
 
 
1394
1395
1396
 
1383
1384
1385
 
 
 
 
 
 
 
 
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
@@ -1383,14 +1383,15 @@
    # Update target head   head, head_sha = self.refs._follow('HEAD') - target.refs.set_symbolic_ref('HEAD', head) - target['HEAD'] = head_sha - - if not bare: - # Checkout HEAD to target dir - from dulwich.index import build_index_from_tree - build_index_from_tree(target.path, target.index_path(), - target.object_store, target['HEAD'].tree) + if head is not None and head_sha is not None: + target.refs.set_symbolic_ref('HEAD', head) + target['HEAD'] = head_sha + + if not bare: + # Checkout HEAD to target dir + from dulwich.index import build_index_from_tree + build_index_from_tree(target.path, target.index_path(), + target.object_store, target['HEAD'].tree)     return target  
 
286
287
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
290
291
 
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
@@ -286,6 +286,23 @@
  self.assertEqual(shas, [t.head(),   '2a72d929692c41d8554c07f6301757ba18a65d91'])   + def test_clone_no_head(self): + temp_dir = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, temp_dir) + repo_dir = os.path.join(os.path.dirname(__file__), 'data', 'repos') + dest_dir = os.path.join(temp_dir, 'a.git') + shutil.copytree(os.path.join(repo_dir, 'a.git'), + dest_dir, symlinks=True) + r = Repo(dest_dir) + del r.refs["refs/heads/master"] + del r.refs["HEAD"] + t = r.clone(os.path.join(temp_dir, 'b.git'), mkdir=True) + self.assertEqual({ + 'refs/tags/mytag': '28237f4dc30d0d462658d6b937b08a0f0b6ef55a', + 'refs/tags/mytag-packed': + 'b0931cadc54336e78a1d980420e3268903b57a50', + }, t.refs.as_dict()) +   def test_merge_history(self):   r = self._repo = open_repo('simple_merge.git')   shas = [e.commit.id for e in r.get_walker()]