From: Ian Jackson Date: Sun, 22 Jan 2012 16:17:02 +0000 (+0000) Subject: wip before require clean metadata and nothing staged for tb create X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=fbdf67103c969969b564342bb7aed61c8c7ed36b;p=topbloke.git wip before require clean metadata and nothing staged for tb create without this we need to manually create the base branch's first commit so as to avoid switching to the base branch with the user's unstaged commit message modifications, etc. --- diff --git a/tb-create.pl b/tb-create.pl index fcacc6f..9f883f3 100755 --- a/tb-create.pl +++ b/tb-create.pl @@ -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+$//;