chiark / gitweb /
fixes, including reflog
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 23 Jan 2012 01:18:49 +0000 (01:18 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 23 Jan 2012 01:18:49 +0000 (01:18 +0000)
BUGS
Topbloke.pm
tb-create.pl

diff --git a/BUGS b/BUGS
index 819bc52d48a1b2d433f18eb4f06aa1905cb78369..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1 +0,0 @@
-enable reflog ?!
index b6de69022bd325306cdc6109394888c3507bebf6..215ae6bb0c631b218e096cbb16c34129b1c96ca9 100644 (file)
@@ -1,13 +1,15 @@
 # -*- perl -*-
 
+package Topbloke;
+
 use strict;
 use warnings;
 
 use POSIX;
 use IO::File;
 use IPC::Open2;
-
-package Topbloke;
+use File::Path qw(make_path remove_tree);
+use File::Basename;
 
 BEGIN {
     use Exporter   ();
@@ -18,7 +20,7 @@ BEGIN {
     @EXPORT      = qw(debug
                      run_git run_git_1line run_git_check_nooutput
                      run_git_test_anyoutput git_get_object
-                     git_config git_dir chdir_toplevel
+                     git_config git_dir chdir_toplevel enable_reflog
                      current_branch parse_patch_spec parse_patch_name
                      setup_config check_no_unwanted_metadata
                      patch_matches_spec
@@ -95,8 +97,7 @@ sub git_get_object ($) {
     my ($objname) = @_;
     our ($gro_pid, $gro_out, $gro_in);
     if (!$gro_pid) {
-       $gro_pid = IPC::Open2::open2($gro_out, $gro_in,
-                                    $git_command, qw(cat-file --batch))
+       $gro_pid = open2($gro_out, $gro_in, $git_command, qw(cat-file --batch))
            or die $!;
     }
     #debug("git_get_object $objname");
@@ -155,6 +156,16 @@ sub chdir_toplevel () {
     chdir $toplevel or die "chdir toplevel $toplevel: $!\n";
 }
 
+sub enable_reflog ($) {
+    my ($branchref) = @_;
+    $branchref =~ m#^refs/# or die;
+    my $logsdir = git_dir().'/logs/';
+    my $dirname = $logsdir.dirname($branchref);
+    make_path($dirname) or die "$dirname $!";
+    open REFLOG, '>>', $logsdir.$branchref or die "$logsdir$branchref $!";
+    close REFLOG or die $!;
+}    
+
 sub current_branch () {
     open R, git_dir().'/HEAD' or die "open HEAD $!";
     my $ref = <R>;  defined $ref or die $!;
index a3fd1b37e6c86d23288d19ee84616eece18a8692..5c620f35fb30bd5a0186c2f661ac982619d375b2 100755 (executable)
@@ -77,9 +77,10 @@ setup_config();
 
 #----- subroutines for setup
 
-sub create_and_switch ($) {
-    my ($branchref) = @_;
-    run_git(qw(update-ref -m), "tb-create base", $branchref, 'HEAD');
+sub create_and_switch ($$) {
+    my ($branchref, $what) = @_;
+    enable_reflog($branchref);
+    run_git(qw(update-ref -m), "tb-create $newpatch $what", $branchref, 'HEAD');
     run_git(qw(symbolic-ref HEAD), $branchref);
 }
 
@@ -103,10 +104,7 @@ if (lstat '.topbloke') {
 }
 
 my $baseref = "refs/topbloke-bases/$newpatch";
-create_and_switch($baseref);
-
-run_git(qw(update-ref -m), "tb-create base $newpatch", $baseref, 'HEAD');
-run_git(qw(symbolic-ref HEAD), $baseref);
+create_and_switch($baseref, 'base');
 
 meta_and_stage('msg', "# not applicable\n");
 meta_and_stage('deps', "# not applicable\n");
@@ -117,12 +115,12 @@ if ($current->{Kind} eq 'foreign') {
     meta_and_stage('pflags', '');
 }
 
-run_git(qw(commit -q -m), "tb-create base $newpatch");
+run_git(qw(commit -q -m), "tb-create $newpatch base");
 
 #----- create the tip branch
 
 my $tipref = "refs/topbloke-tips/$newpatch";
-create_and_switch($tipref);
+create_and_switch($tipref, 'tip');
 
 my $nm = wf_start('.topbloke/msg');
 wf($nm, "From: $author\n");
@@ -148,4 +146,4 @@ meta_and_stage('deps', "$current->{DepSpec}\n");
 flagsfile_add_flag('included',$newpatch);
 stage_meta('included');
 
-run_git(qw(commit -q -m), "tb-create tip $spec->{Nick}\n$newpatch\n");
+run_git(qw(commit -q -m), "tb-create $newpatch tip");