Fossil

Check-in [61132cef]
Login

Check-in [61132cef]

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

Overview
Comment:The "fossil open" command now tolerates the repository file being in the check-out directory without requiring the -f flag. See forum post bc5f8f6e59 for the discussion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 61132cefacba2ea1396ba782f3e2d2385e2a1bee9cdcc889f7f78510a5ce9214
User & Date: drh 2021-04-06 10:47:43
Context
2021-04-07
03:10
Make some auxiliary Th1 variables available within skins' header/footer. For /doc, /uv and /wiki pages put into "artifact_hashsum" variable (and also into its page-specific variant) a full identifier of the requested file or wiki. For /wiki pages also provide "wiki_editor" and "wiki_timestamp" variables. There is an old forum thread on the topic and another thread on a little bit related issue. ... (check-in: 80e062e1 user: george tags: th1-doc-vars)
02:35
Resolved /chat-poll crash when xfrom is null, as described in forum post e0be0eeb4c. ... (check-in: 92b5cc21 user: stephan tags: trunk)
2021-04-06
10:47
The "fossil open" command now tolerates the repository file being in the check-out directory without requiring the -f flag. See forum post bc5f8f6e59 for the discussion. ... (check-in: 61132cef user: drh tags: trunk)
2021-04-03
10:56
build.wiki: dockerfile example now uses alpine v3.13 instead of alpine edge because 3.14+ unduly breaks stuff on many currently-common host OSes. ... (check-in: 63ed857a user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

3486
3487
3488
3489
3490
3491
3492

3493
3494
3495
3496
3497
3498
3499
  int bForce = 0;                /* --force.  Open even if non-empty dir */
  static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
  const char *zWorkDir;          /* --workdir value */
  const char *zRepo = 0;         /* Name of the repository file */
  const char *zRepoDir = 0;      /* --repodir value */
  char *zPwd;                    /* Initial working directory */
  int isUri = 0;                 /* True if REPOSITORY is a URI */


  url_proxy_options();
  emptyFlag = find_option("empty",0,0)!=0;
  keepFlag = find_option("keep",0,0)!=0;
  forceMissingFlag = find_option("force-missing",0,0)!=0;
  allowNested = find_option("nested",0,0)!=0;
  setmtimeFlag = find_option("setmtime",0,0)!=0;







>







3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
  int bForce = 0;                /* --force.  Open even if non-empty dir */
  static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
  const char *zWorkDir;          /* --workdir value */
  const char *zRepo = 0;         /* Name of the repository file */
  const char *zRepoDir = 0;      /* --repodir value */
  char *zPwd;                    /* Initial working directory */
  int isUri = 0;                 /* True if REPOSITORY is a URI */
  int nLocal;                    /* Number of preexisting files in cwd */

  url_proxy_options();
  emptyFlag = find_option("empty",0,0)!=0;
  keepFlag = find_option("keep",0,0)!=0;
  forceMissingFlag = find_option("force-missing",0,0)!=0;
  allowNested = find_option("nested",0,0)!=0;
  setmtimeFlag = find_option("setmtime",0,0)!=0;
3532
3533
3534
3535
3536
3537
3538
3539




3540
3541
3542
3543
3544
3545
3546
        fossil_fatal("cannot create directory %s", zWorkDir);
      }
    }
    if( file_chdir(zWorkDir, 0) ){
      fossil_fatal("unable to make %s the working directory", zWorkDir);
    }
  }
  if( keepFlag==0 && bForce==0 && file_directory_size(".", 0, 1)>0 ){




    fossil_fatal("directory %s is not empty\n"
                 "use the -f or --force option to override", file_getcwd(0,0));
  }

  if( db_open_local_v2(0, allowNested) ){
    fossil_fatal("there is already an open tree at %s", g.zLocalRoot);
  }







|
>
>
>
>







3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
        fossil_fatal("cannot create directory %s", zWorkDir);
      }
    }
    if( file_chdir(zWorkDir, 0) ){
      fossil_fatal("unable to make %s the working directory", zWorkDir);
    }
  }
  if( keepFlag==0
   && bForce==0
   && (nLocal = file_directory_size(".", 0, 1))>0
   && (nLocal>1 || isUri || !file_in_cwd(zRepo))
  ){
    fossil_fatal("directory %s is not empty\n"
                 "use the -f or --force option to override", file_getcwd(0,0));
  }

  if( db_open_local_v2(0, allowNested) ){
    fossil_fatal("there is already an open tree at %s", g.zLocalRoot);
  }

Changes to src/file.c.

1364
1365
1366
1367
1368
1369
1370

1371
1372
1373
1374
1375
1376
1377
  fossil_print("  file_isfile_or_link    = %d\n", file_isfile_or_link(zPath));
  fossil_print("  file_islink            = %d\n", file_islink(zPath));
  fossil_print("  file_isexe(RepoFILE)   = %d\n", file_isexe(zPath,RepoFILE));
  fossil_print("  file_isdir(RepoFILE)   = %d\n", file_isdir(zPath,RepoFILE));
  fossil_print("  file_is_repository     = %d\n", file_is_repository(zPath));
  fossil_print("  file_is_reserved_name  = %d\n",
                                             file_is_reserved_name(zFull,-1));

  blob_reset(&x);
  if( reset ) resetStat();
}

/*
** COMMAND: test-file-environment
**







>







1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
  fossil_print("  file_isfile_or_link    = %d\n", file_isfile_or_link(zPath));
  fossil_print("  file_islink            = %d\n", file_islink(zPath));
  fossil_print("  file_isexe(RepoFILE)   = %d\n", file_isexe(zPath,RepoFILE));
  fossil_print("  file_isdir(RepoFILE)   = %d\n", file_isdir(zPath,RepoFILE));
  fossil_print("  file_is_repository     = %d\n", file_is_repository(zPath));
  fossil_print("  file_is_reserved_name  = %d\n",
                                             file_is_reserved_name(zFull,-1));
  fossil_print("  file_in_cwd            = %d\n", file_in_cwd(zPath));
  blob_reset(&x);
  if( reset ) resetStat();
}

/*
** COMMAND: test-file-environment
**
1693
1694
1695
1696
1697
1698
1699

































1700
1701
1702
1703
1704
1705
1706
  for(i=2; i<g.argc; i++){
    if( file_tree_name(g.argv[i], &x, absoluteFlag, 1) ){
      fossil_print("%s\n", blob_buffer(&x));
      blob_reset(&x);
    }
  }
}


































/*
** Parse a URI into scheme, host, port, and path.
*/
void file_parse_uri(
  const char *zUri,
  Blob *pScheme,







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
  for(i=2; i<g.argc; i++){
    if( file_tree_name(g.argv[i], &x, absoluteFlag, 1) ){
      fossil_print("%s\n", blob_buffer(&x));
      blob_reset(&x);
    }
  }
}

/*
** zFile is the name of a file.  Return true if that file is in the
** current working directory (the "pwd" or file_getcwd() directory).
** Return false if the file is someplace else.
*/
int file_in_cwd(const char *zFile){
  char *zFull = file_canonical_name_dup(zFile);
  char *zCwd = file_getcwd(0,0);
  size_t nCwd = strlen(zCwd);
  size_t nFull = strlen(zFull);
  int rc = 1;
  int (*xCmp)(const char*,const char*,int);

  if( filenames_are_case_sensitive() ){
    xCmp = fossil_strncmp;
  }else{
    xCmp = fossil_strnicmp;
  }

  if( nFull>nCwd+1
   && xCmp(zFull,zCwd,nCwd)==0
   && zFull[nCwd]=='/'
   && strchr(zFull+nCwd+1, '/')==0
  ){
    rc = 1;
  }else{
    rc = 0;
  }
  fossil_free(zFull);
  fossil_free(zCwd);
  return rc;
}

/*
** Parse a URI into scheme, host, port, and path.
*/
void file_parse_uri(
  const char *zUri,
  Blob *pScheme,