Diff
Not logged in

Differences From:

File src/name.c part of check-in [41cf3e7c1d] - Remove string_xform.c from the makefile. Require a "sym-" prefix on tags used to name baselines or branches. The prefix is omitted when the tag is used for this purpose; it is only there to avoid ambiguity with other built-in tag names. by drh on 2008-02-06 03:05:42. [view]

To:

File src/name.c part of check-in [d1c9938025] - Change behavior of Fossil's tag handling.
  1. All subcommands of command tag prepends a prefix sym- infront of every tag name passed to them. Tags beginning with sym- are special in Fossil as they might serve as replacement of a UUID they are attached to.

    Further, tag list will only list all tags beginning with sym- but with that prefix removed during display as default.

    All subcommands can get passed an option --raw, that prevent the prepending of the prefix sym- in front of the tag name. tag list will report all tags without removing any prefix if called with option --raw.
  1. If a command takes a tag name that may be confused with a UUID, the command did interpret that parameter as a UUID instead as a tag name. Such tags might now be prefixed with a tag: to enforce the command to take them as tag name instead of a UUID. For example:
            fossil tag add abcde $uuid
            :
            fossil update tag:abcde
          
    without the prefix tag: fossil would try to update to a UUID beginning with abcde. If no such UUID was found, fossil will complain and exit.
by cle on 2008-07-27 18:35:06. [view]

@@ -47,25 +47,32 @@
   sz = blob_size(pName);
   if( sz>UUID_SIZE || sz<4 || !validate16(blob_buffer(pName), sz) ){
     Stmt q;
     Blob uuid;
+    static const char prefix[] = "tag:";
+    static const int preflen = sizeof(prefix)-1;
+    const char *zName = blob_str(pName);
+
+    if( strncmp(zName, prefix, preflen)==0 ){
+      zName += preflen;
+    }
 
     db_prepare(&q,
       "SELECT (SELECT uuid FROM blob WHERE rid=objid)"
       "  FROM tagxref JOIN event ON rid=objid"
-      " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='sym-'||%B)"
+      " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='sym-'||%Q)"
       "   AND tagtype>0"
       "   AND value IS NULL"
       " ORDER BY event.mtime DESC",
-      pName
+      zName
     );
     blob_zero(&uuid);
     if( db_step(&q)==SQLITE_ROW ){
       db_column_blob(&q, 0, &uuid);
     }
     db_finalize(&q);
     if( blob_size(&uuid)==0 ){
-      fossil_error(iErrPriority, "not a valid object name: %b", pName);
+      fossil_error(iErrPriority, "not a valid object name: %s", zName);
       blob_reset(&uuid);
       return 1;
     }else{
       blob_reset(pName);