Fossil SCM
Add the "--workdir DIR" option to the "fossil open" command.
Commit
0629d2a0d70de6f4e9ca74a724c74599640810e09f8f4a066236f8073f64fc25
Parent
ec5a063bdc1b711…
1 file changed
+22
-1
M
src/db.c
+22
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3088,10 +3088,11 @@ | ||
| 3088 | 3088 | ** --nested Allow opening a repository inside an opened checkout |
| 3089 | 3089 | ** --force-missing Force opening a repository with missing content |
| 3090 | 3090 | ** --setmtime Set timestamps of all files to match their SCM-side |
| 3091 | 3091 | ** times (the timestamp of the last checkin which modified |
| 3092 | 3092 | ** them). |
| 3093 | +** --workdir DIR Use DIR as the working directory instead of ".". | |
| 3093 | 3094 | ** |
| 3094 | 3095 | ** See also: close |
| 3095 | 3096 | */ |
| 3096 | 3097 | void cmd_open(void){ |
| 3097 | 3098 | int emptyFlag; |
| @@ -3099,28 +3100,48 @@ | ||
| 3099 | 3100 | int forceMissingFlag; |
| 3100 | 3101 | int allowNested; |
| 3101 | 3102 | int allowSymlinks; |
| 3102 | 3103 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 3103 | 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 */ | |
| 3104 | 3108 | |
| 3105 | 3109 | url_proxy_options(); |
| 3106 | 3110 | emptyFlag = find_option("empty",0,0)!=0; |
| 3107 | 3111 | keepFlag = find_option("keep",0,0)!=0; |
| 3108 | 3112 | forceMissingFlag = find_option("force-missing",0,0)!=0; |
| 3109 | 3113 | allowNested = find_option("nested",0,0)!=0; |
| 3110 | 3114 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 3115 | + zWorkDir = find_option("workdir",0,1); | |
| 3116 | + | |
| 3111 | 3117 | |
| 3112 | 3118 | /* We should be done with options.. */ |
| 3113 | 3119 | verify_all_options(); |
| 3114 | 3120 | |
| 3115 | 3121 | if( g.argc!=3 && g.argc!=4 ){ |
| 3116 | 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 | + } | |
| 3117 | 3138 | } |
| 3118 | 3139 | if( !allowNested && db_open_local(0) ){ |
| 3119 | 3140 | fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot); |
| 3120 | 3141 | } |
| 3121 | - db_open_repository(g.argv[2]); | |
| 3142 | + db_open_repository(zRepo); | |
| 3122 | 3143 | |
| 3123 | 3144 | /* Figure out which revision to open. */ |
| 3124 | 3145 | if( !emptyFlag ){ |
| 3125 | 3146 | if( g.argc==4 ){ |
| 3126 | 3147 | g.zOpenRevision = g.argv[3]; |
| 3127 | 3148 |
| --- 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 |