chiark / gitweb /
wip before require clean metadata and nothing staged for tb create
[topbloke.git] / tb-create.pl
index fcacc6f13410cade3921d6efdb2e529333a16804..9f883f3b32da2bb0443dee28aab9a3a869a4340d 100755 (executable)
@@ -44,12 +44,14 @@ length($spec->{Date})==18 or die "partial date specified, not supported\n";
 check_no_unwanted_metadata('HEAD')
     if $current->{Kind} ne 'tip';
 
+run_git_check_nooutput('cannot create new topbloke branch with staged files',
+                      qw(diff --cached --name-only HEAD --));
+
 # 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.
+# version differs from HEAD) we keep that and stage it.
 
 my $newbranch = "$spec->{Email}\@$spec->{Domain}/$spec->{Date}/$spec->{Nick}";
 
@@ -59,9 +61,19 @@ printf "creating %s\n", $newbranch;
 
 setup_config();
 
-run_git__anyoutput(qw(diff --cached --name-only HEAD --
+my $user_edited_msg = 
+    run_git_test_anyoutput(qw(diff --name-only HEAD -- .topbloke/msg));
+
+my $baseref = "refs/topbloke-bases/$newbranch";
+run_git(qw(update-ref -m), "tb-create base", $baseref, 'HEAD');
+
+open GIT, "|-", 'git', qw(update-index --index-info) or die $!;
+foreach my $file (qw(msg deps)) {
+    run_git(qw(update-index --cacheinfo 0644), $notapplicable_sha1,
+           ".topbloke/$file");
+
+
 
-if (!run_git_test_anyoutput(qw(diff --name-only HEAD -- .topbloke/msg)) {
     my $nm = wf_start('.topbloke/msg');
     my $author = run_git_1line(qw(var GIT_AUTHOR_IDENT));
     $author =~ s/ \d+ [-+]\d+$//;