Fossil SCM

Add the "--workdir DIR" option to the "fossil open" command.

drh 2020-08-07 12:41 trunk
Commit 0629d2a0d70de6f4e9ca74a724c74599640810e09f8f4a066236f8073f64fc25
1 file changed +22 -1
+22 -1
--- src/db.c
+++ src/db.c
@@ -3088,10 +3088,11 @@
30883088
** --nested Allow opening a repository inside an opened checkout
30893089
** --force-missing Force opening a repository with missing content
30903090
** --setmtime Set timestamps of all files to match their SCM-side
30913091
** times (the timestamp of the last checkin which modified
30923092
** them).
3093
+** --workdir DIR Use DIR as the working directory instead of ".".
30933094
**
30943095
** See also: close
30953096
*/
30963097
void cmd_open(void){
30973098
int emptyFlag;
@@ -3099,28 +3100,48 @@
30993100
int forceMissingFlag;
31003101
int allowNested;
31013102
int allowSymlinks;
31023103
int setmtimeFlag; /* --setmtime. Set mtimes on files */
31033104
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
3105
+ const char *zWorkDir; /* --workdir value */
3106
+ const char *zRepo = 0; /* Name of the repository file */
3107
+ Blob normalizedRepoName; /* Normalized repository filename */
31043108
31053109
url_proxy_options();
31063110
emptyFlag = find_option("empty",0,0)!=0;
31073111
keepFlag = find_option("keep",0,0)!=0;
31083112
forceMissingFlag = find_option("force-missing",0,0)!=0;
31093113
allowNested = find_option("nested",0,0)!=0;
31103114
setmtimeFlag = find_option("setmtime",0,0)!=0;
3115
+ zWorkDir = find_option("workdir",0,1);
3116
+
31113117
31123118
/* We should be done with options.. */
31133119
verify_all_options();
31143120
31153121
if( g.argc!=3 && g.argc!=4 ){
31163122
usage("REPOSITORY-FILENAME ?VERSION?");
3123
+ }
3124
+ zRepo = g.argv[2];
3125
+ blob_init(&normalizedRepoName, 0, 0);
3126
+ if( zWorkDir ){
3127
+ file_canonical_name(zRepo, &normalizedRepoName, 0);
3128
+ zRepo = blob_str(&normalizedRepoName);
3129
+ if( file_isdir(zWorkDir, ExtFILE)!=1 ){
3130
+ file_mkfolder(zWorkDir, ExtFILE, 0, 0);
3131
+ if( file_mkdir(zWorkDir, ExtFILE, 0) ){
3132
+ fossil_fatal("cannot create directory %s\n", zWorkDir);
3133
+ }
3134
+ }
3135
+ if( file_chdir(zWorkDir, 0) ){
3136
+ fossil_fatal("unable to make %s the working directory\n", zWorkDir);
3137
+ }
31173138
}
31183139
if( !allowNested && db_open_local(0) ){
31193140
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
31203141
}
3121
- db_open_repository(g.argv[2]);
3142
+ db_open_repository(zRepo);
31223143
31233144
/* Figure out which revision to open. */
31243145
if( !emptyFlag ){
31253146
if( g.argc==4 ){
31263147
g.zOpenRevision = g.argv[3];
31273148
--- src/db.c
+++ src/db.c
@@ -3088,10 +3088,11 @@
3088 ** --nested Allow opening a repository inside an opened checkout
3089 ** --force-missing Force opening a repository with missing content
3090 ** --setmtime Set timestamps of all files to match their SCM-side
3091 ** times (the timestamp of the last checkin which modified
3092 ** them).
 
3093 **
3094 ** See also: close
3095 */
3096 void cmd_open(void){
3097 int emptyFlag;
@@ -3099,28 +3100,48 @@
3099 int forceMissingFlag;
3100 int allowNested;
3101 int allowSymlinks;
3102 int setmtimeFlag; /* --setmtime. Set mtimes on files */
3103 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
 
 
 
3104
3105 url_proxy_options();
3106 emptyFlag = find_option("empty",0,0)!=0;
3107 keepFlag = find_option("keep",0,0)!=0;
3108 forceMissingFlag = find_option("force-missing",0,0)!=0;
3109 allowNested = find_option("nested",0,0)!=0;
3110 setmtimeFlag = find_option("setmtime",0,0)!=0;
 
 
3111
3112 /* We should be done with options.. */
3113 verify_all_options();
3114
3115 if( g.argc!=3 && g.argc!=4 ){
3116 usage("REPOSITORY-FILENAME ?VERSION?");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3117 }
3118 if( !allowNested && db_open_local(0) ){
3119 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
3120 }
3121 db_open_repository(g.argv[2]);
3122
3123 /* Figure out which revision to open. */
3124 if( !emptyFlag ){
3125 if( g.argc==4 ){
3126 g.zOpenRevision = g.argv[3];
3127
--- src/db.c
+++ src/db.c
@@ -3088,10 +3088,11 @@
3088 ** --nested Allow opening a repository inside an opened checkout
3089 ** --force-missing Force opening a repository with missing content
3090 ** --setmtime Set timestamps of all files to match their SCM-side
3091 ** times (the timestamp of the last checkin which modified
3092 ** them).
3093 ** --workdir DIR Use DIR as the working directory instead of ".".
3094 **
3095 ** See also: close
3096 */
3097 void cmd_open(void){
3098 int emptyFlag;
@@ -3099,28 +3100,48 @@
3100 int forceMissingFlag;
3101 int allowNested;
3102 int allowSymlinks;
3103 int setmtimeFlag; /* --setmtime. Set mtimes on files */
3104 static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
3105 const char *zWorkDir; /* --workdir value */
3106 const char *zRepo = 0; /* Name of the repository file */
3107 Blob normalizedRepoName; /* Normalized repository filename */
3108
3109 url_proxy_options();
3110 emptyFlag = find_option("empty",0,0)!=0;
3111 keepFlag = find_option("keep",0,0)!=0;
3112 forceMissingFlag = find_option("force-missing",0,0)!=0;
3113 allowNested = find_option("nested",0,0)!=0;
3114 setmtimeFlag = find_option("setmtime",0,0)!=0;
3115 zWorkDir = find_option("workdir",0,1);
3116
3117
3118 /* We should be done with options.. */
3119 verify_all_options();
3120
3121 if( g.argc!=3 && g.argc!=4 ){
3122 usage("REPOSITORY-FILENAME ?VERSION?");
3123 }
3124 zRepo = g.argv[2];
3125 blob_init(&normalizedRepoName, 0, 0);
3126 if( zWorkDir ){
3127 file_canonical_name(zRepo, &normalizedRepoName, 0);
3128 zRepo = blob_str(&normalizedRepoName);
3129 if( file_isdir(zWorkDir, ExtFILE)!=1 ){
3130 file_mkfolder(zWorkDir, ExtFILE, 0, 0);
3131 if( file_mkdir(zWorkDir, ExtFILE, 0) ){
3132 fossil_fatal("cannot create directory %s\n", zWorkDir);
3133 }
3134 }
3135 if( file_chdir(zWorkDir, 0) ){
3136 fossil_fatal("unable to make %s the working directory\n", zWorkDir);
3137 }
3138 }
3139 if( !allowNested && db_open_local(0) ){
3140 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
3141 }
3142 db_open_repository(zRepo);
3143
3144 /* Figure out which revision to open. */
3145 if( !emptyFlag ){
3146 if( g.argc==4 ){
3147 g.zOpenRevision = g.argv[3];
3148

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button