Fossil

Check-in [9acf0bcd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correctly detect when an artifact prefix does not match any artifact. Provide better error messages for non-matching and ambiguous artifact prefixes. Fix for ticket [d0a7fc67e9].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9acf0bcdbe76cae81152a3485e47e4be1cf938ae
User & Date: drh 2008-10-26 15:59:38
Context
2008-10-26
21:30
Remove the unused inherit-anon configuration attribute. Fix the automatic redirect that follows a login operation. Fix "config push user" on the server side. check-in: 0600b278 user: drh tags: trunk
15:59
Correctly detect when an artifact prefix does not match any artifact. Provide better error messages for non-matching and ambiguous artifact prefixes. Fix for ticket [d0a7fc67e9]. check-in: 9acf0bcd user: drh tags: trunk
02:35
Fix the "number of tickets" counter on the "stats" webpage. check-in: 1e82c4aa user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/name.c.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96







97
98
99
100
101
102
103
    }
  }
  blob_materialize(pName);
  canonical16(blob_buffer(pName), sz);
  if( sz==UUID_SIZE ){
    rc = db_int(1, "SELECT 0 FROM blob WHERE uuid=%B", pName);
    if( rc ){
      fossil_error(iErrPriority, "unknown object: %b", pName);
      blob_reset(pName);
    }
  }else if( sz<UUID_SIZE && sz>=4 ){
    char zOrig[UUID_SIZE+1];
    memcpy(zOrig, blob_buffer(pName), sz);
    zOrig[sz] = 0;
    blob_reset(pName);
    db_blob(pName, "SELECT uuid FROM blob WHERE uuid>='%s'", zOrig);
    if( blob_size(pName)!=UUID_SIZE ){
      fossil_error(iErrPriority, "no match: %s", zOrig);
      rc = 1;
    }else{
      zOrig[sz-1]++;
      if( db_exists("SELECT 1 FROM blob WHERE uuid>%B AND uuid<'%s'",
                    pName, zOrig) ){
         zOrig[sz-1]--;
         fossil_error(iErrPriority, "non-unique name prefix: %s", zOrig);
         rc = 1;
      }else{
         rc = 0;
      }
    }







  }else{
    rc = 0;
  }
  return rc;
}

/*







|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    }
  }
  blob_materialize(pName);
  canonical16(blob_buffer(pName), sz);
  if( sz==UUID_SIZE ){
    rc = db_int(1, "SELECT 0 FROM blob WHERE uuid=%B", pName);
    if( rc ){
      fossil_error(iErrPriority, "no such artifact: %b", pName);
      blob_reset(pName);
    }
  }else if( sz<UUID_SIZE && sz>=4 ){
    Stmt q;
    char zOrig[UUID_SIZE+1];
    memcpy(zOrig, blob_buffer(pName), sz);
    zOrig[sz] = 0;
    blob_reset(pName);
    db_prepare(&q, "SELECT uuid FROM blob"
                   " WHERE uuid>='%s'"
                   "   AND substr(uuid,1,%d)='%s'",
                   zOrig, sz, zOrig);
    if( db_step(&q)!=SQLITE_ROW ){
      db_finalize(&q);
      fossil_error(iErrPriority, "no artifacts match the prefix \"%s\"", zOrig);
      return 1;
    }
    blob_append(pName, db_column_text(&q, 0), db_column_bytes(&q, 0));
    if( db_step(&q)==SQLITE_ROW ){
      fossil_error(iErrPriority, 
         "multiple artifacts match the prefix \"%s\"",
         zOrig
      );
      blob_reset(pName);
      db_finalize(&q);
      return 1;
    }
    db_finalize(&q);
    rc = 0;
  }else{
    rc = 0;
  }
  return rc;
}

/*