X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tb-create.pl;h=591a72e0bb397b4264e073c1986b8c842a1a8a1a;hb=98c96c9695b93d1ed7cf2ea81d1851364faad0ba;hp=f0bd5635128f1a79cc3cfda8fe185770610579a3;hpb=e0dc5dcfab767e25d4abb8eb65bdb797d1a9d0f9;p=topbloke.git diff --git a/tb-create.pl b/tb-create.pl index f0bd563..591a72e 100755 --- a/tb-create.pl +++ b/tb-create.pl @@ -41,6 +41,16 @@ if (!defined $spec->{Date}) { length($spec->{Date})==18 or die "partial date specified, not supported\n"; +check_no_unwanted_metadata('HEAD') + if $current->{Kind} ne 'tip'; + +# For the metadata files in .topbloke, we hope that the user +# doesn't modify them. If they do then they get to keep all the pieces. +# +# For .topbloke/msg, if it's modified by the user (ie, if working +# version differs from HEAD) we keep that, and we stage it unless +# the cached version differs from the HEAD. + my $newbranch = "$spec->{Email}\@$spec->{Domain}/$spec->{Date}/$spec->{Nick}"; $newbranch = run_git_1line(qw(check-ref-format --print), $newbranch); @@ -48,3 +58,35 @@ $newbranch = run_git_1line(qw(check-ref-format --print), $newbranch); printf "creating %s\n", $newbranch; setup_config(); + +if (!run_git_test_anyoutput(qw(diff --name-only HEAD -- .topbloke/msg)) { + open NM, '>', ".topbloke/msg.tmp" or die $!; + my $author = run_git_1line(qw(var GIT_AUTHOR_IDENT)); + $author =~ s/ \d+ [-+]\d+$//; + print NM "From: $author\n" or die $!; + foreach my $h (qw(To CC BCC)) { + my $estatus; + run_git(\$estatus, sub { print NM "$h: $_" or die $!; }, + qw(config), "topbloke.".lc $h); + die "$h $estatus" unless $estatus==0 || $estatus==256; + } + $subjprefix = git_config('topbloke.subjectprefix', ''); + print NM {Nick} + + + +Signed-off-by: $author +END + run_git(qw(add .topbloke/msg)); + print " created and staged new .topbloke/msg\n"; +} else { + if (!run_git_test_anyoutput(qw(diff --cached --name-only HEAD -- + .topblokemsg))) { + print " staged your modified .topbloke/msg\n"; + run_git(qw(add .topbloke/msg)); + } else { + print " left your (partially staged?) .topbloke/msg\n"; + } +} +