<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,9 @@
 Revision history for Perl module Git::PurePerl:
 
+0.42
+     - allow put_object to update other heads than just 'master'
+       (thanks to martijn)
+
 0.41 Tue Apr 21 20:41:07 BST 2009
      - allow subdirectories in .git/refs/*/ (thanks to martijn)
      - run protocol.t test with --base-path to not care about where</diff>
      <filename>CHANGES</filename>
    </modified>
    <modified>
      <diff>@@ -295,23 +295,26 @@ sub all_objects {
 }
 
 sub put_object {
-    my ( $self, $object ) = @_;
+    my ( $self, $object, $ref ) = @_;
     $self-&gt;loose-&gt;put_object($object);
 
     if ( $object-&gt;kind eq 'commit' ) {
-        $self-&gt;update_master( $object-&gt;sha1 );
+        $ref = 'master' unless $ref;
+        $self-&gt;update_ref( $ref, $object-&gt;sha1 );
     }
 }
 
-sub update_master {
-    my ( $self, $sha1 ) = @_;
-    my $master = file( $self-&gt;gitdir, 'refs', 'heads', 'master' );
-    $master-&gt;parent-&gt;mkpath;
-    my $master_fh = $master-&gt;openw;
-    $master_fh-&gt;print($sha1) || die &quot;Error writing to $master&quot;;
+sub update_ref {
+    my ( $self, $refname, $sha1 ) = @_;
+    my $ref = file( $self-&gt;gitdir, 'refs', 'heads', $refname );
+    $ref-&gt;parent-&gt;mkpath;
+    my $ref_fh = $ref-&gt;openw;
+    $ref_fh-&gt;print($sha1) || die &quot;Error writing to $ref&quot;;
+
+    # FIXME is this always what we want?
     my $head = file( $self-&gt;gitdir, 'HEAD' );
     my $head_fh = $head-&gt;openw;
-    $head_fh-&gt;print('ref: refs/heads/master')
+    $head_fh-&gt;print(&quot;ref: refs/heads/$refname&quot;)
         || die &quot;Error writing to $head&quot;;
 }
 
@@ -417,7 +420,7 @@ sub clone {
         = Git::PurePerl::Pack::WithoutIndex-&gt;new( filename =&gt; $filename );
     $pack-&gt;create_index();
 
-    $self-&gt;update_master($head);
+    $self-&gt;update_ref( master =&gt; $head );
 }
 
 sub _add_file {</diff>
      <filename>lib/Git/PurePerl.pm</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>586199f673641498ca51cf1a83a83b0bc6fddac9</id>
    </parent>
  </parents>
  <author>
    <name>Leon Brocard</name>
    <email>acme@astray.com</email>
  </author>
  <url>http://github.com/acme/git-pureperl/commit/4642624c353903a4508b5c79e142c01597da9a82</url>
  <id>4642624c353903a4508b5c79e142c01597da9a82</id>
  <committed-date>2009-04-23T09:02:08-07:00</committed-date>
  <authored-date>2009-04-23T09:02:08-07:00</authored-date>
  <message>allow put_object to update other heads than just 'master' (thanks to martijn)</message>
  <tree>0fa5ae99cd83a4a223e63cb4c4b05f7f39a4ccce</tree>
  <committer>
    <name>Leon Brocard</name>
    <email>acme@astray.com</email>
  </committer>
</commit>
