# -*- 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 ();
@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
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");
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 $!;
#----- 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);
}
}
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");
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");
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");