fast-import uses null_sha1 for empty branches. It doesn't make a
null_sha1 parent nor writes out a branch with null_sha1 head. But
for notemodify and tag commands there is no check for null_sha1
and so bad tag/notes are produced instead of a error message.
Dmitry Ivankov (2):
fast-import: don't allow to tag empty branch
fast-import: don't allow to note on empty branch
fast-import.c | 4 ++++
t/t9300-fast-import.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
--
1.7.3.4
'reset' command makes fast-import start a branch from scratch. It's name
is kept in lookup table but it's sha1 is null_sha1 (special value).
'tag' command can be used to tag a branch by it's name. lookup_branch()
is used it that case and it doesn't check for null_sha1. So fast-import
writes a tag for null_sha1 object instead of giving a error.
Add a check to deny tagging an empty branch and add a corresponding test.
Signed-off-by: Dmitry Ivankov <redacted>
---
fast-import.c | 2 ++
t/t9300-fast-import.sh | 12 ++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
@@ -820,6 +820,18 @@ test_expect_success \'test1=`gitrev-listJ|wc-l`&&test0=`gitls-treeJ|wc-l`'+cat>input<<INPUT_END+resetrefs/heads/J2++tagwrong_tag+fromrefs/heads/J2+data<<EOF+Tagbranchthatwasreset.+EOF+INPUT_END+test_expect_success\+'J: tag must fail on empty branch'\+'test_must_fail git fast-import <input'###### series K###
'reset' command makes fast-import start a branch from scratch. It's name
is kept in lookup table but it's sha1 is null_sha1 (special value).
'notemodify' command can be used to add a note on branch head given it's
name. lookup_branch() is used it that case and it doesn't check for
null_sha1. So fast-import writes a note for null_sha1 object instead of
giving a error.
Add a check to deny adding a note on empty branch and add a corresponding
test.
Signed-off-by: Dmitry Ivankov <redacted>
---
fast-import.c | 2 ++
t/t9300-fast-import.sh | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
@@ -1987,6 +1987,23 @@ test_expect_success \'Q: verify second note for second commit'\'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'+cat>input<<EOF+resetrefs/heads/Q0++commitrefs/heads/note-Q0+committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>$GIT_COMMITTER_DATE+data<<COMMIT+Noteforanemptybranch.+COMMIT++Ninlinerefs/heads/Q0+data<<NOTE+somenote+NOTE+EOF+test_expect_success\+'Q: deny note on empty branch'\+'test_must_fail git fast-import <input'###### series R (feature and option)###
Heya,
On Thu, Sep 22, 2011 at 21:47, Dmitry Ivankov [off-list ref] wrote:
'reset' command makes fast-import start a branch from scratch. It's name
is kept in lookup table but it's sha1 is null_sha1 (special value).
'tag' command can be used to tag a branch by it's name. lookup_branch()
is used it that case and it doesn't check for null_sha1. So fast-import
writes a tag for null_sha1 object instead of giving a error.
Add a check to deny tagging an empty branch and add a corresponding test.
Heya,
On Thu, Sep 22, 2011 at 21:47, Dmitry Ivankov [off-list ref] wrote:
'reset' command makes fast-import start a branch from scratch. It's name
is kept in lookup table but it's sha1 is null_sha1 (special value).
'notemodify' command can be used to add a note on branch head given it's
name. lookup_branch() is used it that case and it doesn't check for
null_sha1. So fast-import writes a note for null_sha1 object instead of
giving a error.
Add a check to deny adding a note on empty branch and add a corresponding
test.