Merge branch 'di/fast-import-empty-tag-note-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Oct 2011 02:03:19 +0000 (19:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Oct 2011 02:03:19 +0000 (19:03 -0700)
* 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 branch

1  2 
fast-import.c
diff --combined fast-import.c
index f9347f55bac6b2d9a775c165013aa7107790e5f4,a8a3ad1124bf9220942de5c2887fb68c54e16219..8d8ea3c45c0be5481c7b452c27ee0d163d69fb00
@@@ -722,8 -722,13 +722,8 @@@ static struct branch *new_branch(const 
  
        if (b)
                die("Invalid attempt to create duplicate branch: %s", name);
 -      switch (check_ref_format(name)) {
 -      case 0: break; /* its valid */
 -      case CHECK_REF_FORMAT_ONELEVEL:
 -              break; /* valid, but too few '/', allow anyway */
 -      default:
 +      if (check_refname_format(name, REFNAME_ALLOW_ONELEVEL))
                die("Branch name doesn't conform to GIT standards: %s", name);
 -      }
  
        b = pool_calloc(1, sizeof(struct branch));
        b->name = pool_strdup(name);
@@@ -2411,6 -2416,8 +2411,8 @@@ static void note_change_n(struct branc
        /* <committish> */
        s = lookup_branch(p);
        if (s) {
+               if (is_null_sha1(s->sha1))
+                       die("Can't add a note on empty branch.");
                hashcpy(commit_sha1, s->sha1);
        } else if (*p == ':') {
                uintmax_t commit_mark = strtoumax(p + 1, NULL, 10);
@@@ -2712,6 -2719,8 +2714,8 @@@ static void parse_new_tag(void
        from = strchr(command_buf.buf, ' ') + 1;
        s = lookup_branch(from);
        if (s) {
+               if (is_null_sha1(s->sha1))
+                       die("Can't tag an empty branch.");
                hashcpy(sha1, s->sha1);
                type = OBJ_COMMIT;
        } else if (*from == ':') {