Merge branch 'di/fast-import-empty-tag-note-fix'
* di/fast-import-empty-tag-note-fix: fast-import: don't allow to note on empty branch fast-import: don't allow to tag empty branchmaint
commit
c13975e7fd
|
@ -2411,6 +2411,8 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
|
||||||
/* <committish> */
|
/* <committish> */
|
||||||
s = lookup_branch(p);
|
s = lookup_branch(p);
|
||||||
if (s) {
|
if (s) {
|
||||||
|
if (is_null_sha1(s->sha1))
|
||||||
|
die("Can't add a note on empty branch.");
|
||||||
hashcpy(commit_sha1, s->sha1);
|
hashcpy(commit_sha1, s->sha1);
|
||||||
} else if (*p == ':') {
|
} else if (*p == ':') {
|
||||||
uintmax_t commit_mark = strtoumax(p + 1, NULL, 10);
|
uintmax_t commit_mark = strtoumax(p + 1, NULL, 10);
|
||||||
|
@ -2712,6 +2714,8 @@ static void parse_new_tag(void)
|
||||||
from = strchr(command_buf.buf, ' ') + 1;
|
from = strchr(command_buf.buf, ' ') + 1;
|
||||||
s = lookup_branch(from);
|
s = lookup_branch(from);
|
||||||
if (s) {
|
if (s) {
|
||||||
|
if (is_null_sha1(s->sha1))
|
||||||
|
die("Can't tag an empty branch.");
|
||||||
hashcpy(sha1, s->sha1);
|
hashcpy(sha1, s->sha1);
|
||||||
type = OBJ_COMMIT;
|
type = OBJ_COMMIT;
|
||||||
} else if (*from == ':') {
|
} else if (*from == ':') {
|
||||||
|
|
|
@ -820,6 +820,18 @@ test_expect_success \
|
||||||
'test 1 = `git rev-list J | wc -l` &&
|
'test 1 = `git rev-list J | wc -l` &&
|
||||||
test 0 = `git ls-tree J | wc -l`'
|
test 0 = `git ls-tree J | wc -l`'
|
||||||
|
|
||||||
|
cat >input <<INPUT_END
|
||||||
|
reset refs/heads/J2
|
||||||
|
|
||||||
|
tag wrong_tag
|
||||||
|
from refs/heads/J2
|
||||||
|
data <<EOF
|
||||||
|
Tag branch that was reset.
|
||||||
|
EOF
|
||||||
|
INPUT_END
|
||||||
|
test_expect_success \
|
||||||
|
'J: tag must fail on empty branch' \
|
||||||
|
'test_must_fail git fast-import <input'
|
||||||
###
|
###
|
||||||
### series K
|
### series K
|
||||||
###
|
###
|
||||||
|
@ -1975,6 +1987,23 @@ test_expect_success \
|
||||||
'Q: verify second note for second commit' \
|
'Q: verify second note for second commit' \
|
||||||
'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
|
'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
|
||||||
|
|
||||||
|
cat >input <<EOF
|
||||||
|
reset refs/heads/Q0
|
||||||
|
|
||||||
|
commit refs/heads/note-Q0
|
||||||
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
||||||
|
data <<COMMIT
|
||||||
|
Note for an empty branch.
|
||||||
|
COMMIT
|
||||||
|
|
||||||
|
N inline refs/heads/Q0
|
||||||
|
data <<NOTE
|
||||||
|
some note
|
||||||
|
NOTE
|
||||||
|
EOF
|
||||||
|
test_expect_success \
|
||||||
|
'Q: deny note on empty branch' \
|
||||||
|
'test_must_fail git fast-import <input'
|
||||||
###
|
###
|
||||||
### series R (feature and option)
|
### series R (feature and option)
|
||||||
###
|
###
|
||||||
|
|
Loading…
Reference in New Issue