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);
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 <END or die $!;
+Subject: [${subprefix}PATCH] $spec->{Nick}
+
+<patch description>
+
+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";
+ }
+}
+