Fossil

Check-in [fe87e4cb]
Login

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

Overview
Comment:Add the --use-author flag to "fossil import --git". Patch from Dingyuan Wang.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fe87e4cb9dc0df125be7d5ef66d9ff8e56092a970b1a88803a1c0b3e91121f7d
User & Date: drh 2018-02-12 13:01:20
Context
2018-02-12
16:32
Patch from Pietro Cerutti to enable TCL shared library loading in TH1 on FreeBSD. check-in: 29adfac4 user: drh tags: trunk
13:01
Add the --use-author flag to "fossil import --git". Patch from Dingyuan Wang. check-in: fe87e4cb user: drh tags: trunk
12:55
Fix incorrect setting name in the "fts-config" command. check-in: ceba4881 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/import.c.

   515    515     }
   516    516     zName[i] = 0;
   517    517   }
   518    518   
   519    519   
   520    520   static struct{
   521    521     const char *zMasterName;    /* Name of master branch */
          522  +  int authorFlag;             /* Use author as checkin committer */
   522    523   } ggit;
   523    524   
   524    525   /*
   525    526   ** Read the git-fast-import format from pIn and insert the corresponding
   526    527   ** content into the database.
   527    528   */
   528    529   static void git_fast_import(FILE *pIn){
................................................................................
   617    618   	    gg.aData[got-1] = '\0';
   618    619             gg.zComment = gg.aData;
   619    620             gg.aData = 0;
   620    621             gg.nData = 0;
   621    622           }
   622    623         }
   623    624       }else
   624         -    if( strncmp(zLine, "author ", 7)==0 ){
          625  +    if( (!ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
          626  +        || (ggit.authorFlag && strncmp(zLine, "committer ",10)==0
          627  +            && gg.zUser!=NULL) ){
   625    628         /* No-op */
   626    629       }else
   627    630       if( strncmp(zLine, "mark ", 5)==0 ){
   628    631         trim_newline(&zLine[5]);
   629    632         fossil_free(gg.zMark);
   630    633         gg.zMark = fossil_strdup(&zLine[5]);
   631    634       }else
   632         -    if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
          635  +    if( strncmp(zLine, "tagger ", 7)==0
          636  +        || (ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
          637  +        || strncmp(zLine, "committer ",10)==0 ){
   633    638         sqlite3_int64 secSince1970;
   634    639         z = strchr(zLine, ' ');
   635    640         while( fossil_isspace(*z) ) z++;
   636    641         if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
   637    642         *(++zTo) = '\0';
   638    643         /* Lookup user by contact info. */
   639    644         fossil_free(gg.zUser);
................................................................................
  1601   1606   ** The following formats are currently understood by this command
  1602   1607   **
  1603   1608   **   --git        Import from the git-fast-export file format (default)
  1604   1609   **                Options:
  1605   1610   **                  --import-marks  FILE Restore marks table from FILE
  1606   1611   **                  --export-marks  FILE Save marks table to FILE
  1607   1612   **                  --rename-master NAME Renames the master branch to NAME
         1613  +**                  --use-author    Uses author as the committer
  1608   1614   **
  1609   1615   **   --svn        Import from the svnadmin-dump file format.  The default
  1610   1616   **                behaviour (unless overridden by --flat) is to treat 3
  1611   1617   **                folders in the SVN root as special, following the
  1612   1618   **                common layout of SVN repositories.  These are (by
  1613   1619   **                default) trunk/, branches/ and tags/.  The SVN --deltas
  1614   1620   **                format is supported but not required.
................................................................................
  1725   1731                   || (incrFlag && !find_option("no-rev-tags", 0, 0));
  1726   1732     }else if( gitFlag ){
  1727   1733       markfile_in = find_option("import-marks", 0, 1);
  1728   1734       markfile_out = find_option("export-marks", 0, 1);
  1729   1735       if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
  1730   1736         ggit.zMasterName = "master";
  1731   1737       }
         1738  +    ggit.authorFlag = find_option("use-author", 0, 0)!=0;
  1732   1739     }
  1733   1740     verify_all_options();
  1734   1741   
  1735   1742     if( g.argc!=3 && g.argc!=4 ){
  1736   1743       usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
  1737   1744     }
  1738   1745     if( g.argc==4 ){