X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tb-create.pl;h=591a72e0bb397b4264e073c1986b8c842a1a8a1a;hb=98c96c9695b93d1ed7cf2ea81d1851364faad0ba;hp=79d42749015088e8e6c883348733bad87dcbc7af;hpb=40c98ff5ceb966b62b7bdb42c3ddbb48ddb61bf3;p=topbloke.git diff --git a/tb-create.pl b/tb-create.pl index 79d4274..591a72e 100755 --- a/tb-create.pl +++ b/tb-create.pl @@ -44,6 +44,13 @@ 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); @@ -52,3 +59,34 @@ 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"; + } +} +