Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the new file_skip_userhost() function that will find an skip over a "USER@HOST:" prefix on a filename, if it exists. Use this to extract the USER@HOST prefix from names in the "fossil patch push/pull" commands. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
89a85888539021dd76093725e299199d |
| User & Date: | drh 2021-06-30 17:39:47.716 |
Context
|
2021-06-30
| ||
| 19:14 | Initial changes to support HOST: prefixes on the REPOSITORY argument of the "fossil ui" command. check-in: cb34f1a8ac user: drh tags: remote-ui | |
| 17:57 | Retroactively added a note to the 2.12.1 change log about the allow-symlinks setting no longer syncing, per forum request. check-in: c5dc24d4eb user: stephan tags: trunk | |
| 17:39 | Add the new file_skip_userhost() function that will find an skip over a "USER@HOST:" prefix on a filename, if it exists. Use this to extract the USER@HOST prefix from names in the "fossil patch push/pull" commands. check-in: 89a8588853 user: drh tags: trunk | |
| 13:56 | The argument to the "fossil ui" command is allowed to be a directory name instead of a repository filename. If a directory, repository associated with the checkout at that directory is used. check-in: 9ec744ed79 user: drh tags: trunk | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
if( zName==0 ){
rc = 1;
}else{
rc = file_rmdir(zName);
}
sqlite3_result_int(context, rc);
}
/*
** Return true if the filename given is a valid filename for
** a file in a repository. Valid filenames follow all of the
** following rules:
**
** * Does not begin with "/"
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
if( zName==0 ){
rc = 1;
}else{
rc = file_rmdir(zName);
}
sqlite3_result_int(context, rc);
}
/*
** Check the input argument to see if it looks like it has an prefix that
** indicates a remote file. If so, return the tail of the specification,
** which is the name of the file on the remote system.
**
** If the input argument does not have a prefix that makes it look like
** a remote file reference, then return NULL.
**
** Remote files look like: "HOST:PATH" or "USER@HOST:PATH". Host must
** be a valid hostname, meaning it must follow these rules:
**
** * Only characters [-.a-zA-Z0-9]. No spaces or other punctuation
** * Does not begin or end with -
**
** The USER section, it it exists, must not contain the '@' character.
*/
const char *file_skip_userhost(const char *zIn){
const char *zTail;
int n, i;
if( zIn[0]==':' ) return 0;
zTail = strchr(zIn, ':');
if( zTail==0 ) return 0;
if( zTail - zIn > 10000 ) return 0;
n = (int)(zTail - zIn);
if( zIn[n-1]=='-' || zIn[n-1]=='.' ) return 0;
for(i=n-1; i>0 && zIn[i-1]!='@'; i--){
if( !fossil_isalnum(zIn[i]) && zIn[i]!='-' && zIn[i]!='.' ) return 0;
}
if( zIn[i]=='-' || zIn[i]=='.' || i==1 ) return 0;
if( i>1 ){
i -= 2;
while( i>=0 ){
if( zIn[i]=='@' ) return 0;
i--;
}
}
return zTail+1;
}
/*
** Return true if the filename given is a valid filename for
** a file in a repository. Valid filenames follow all of the
** following rules:
**
** * Does not begin with "/"
|
| ︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 | } /* ** COMMAND: test-simplify-name ** ** Usage: %fossil test-simplify-name FILENAME... ** | | > > > > > > > > > > > | > | 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
}
/*
** COMMAND: test-simplify-name
**
** Usage: %fossil test-simplify-name FILENAME...
**
** Print the simplified versions of each FILENAME. This is used to test
** the file_simplify_name() routine.
**
** If FILENAME is of the form "HOST:PATH" or "USER@HOST:PATH", then remove
** and print the remote host prefix first. This is used to test the
** file_skip_userhost() interface.
*/
void cmd_test_simplify_name(void){
int i;
char *z;
const char *zTail;
for(i=2; i<g.argc; i++){
zTail = file_skip_userhost(g.argv[i]);
if( zTail ){
fossil_print("... ON REMOTE: %.*s\n", (int)(zTail-g.argv[i]), g.argv[i]);
z = mprintf("%s", zTail);
}else{
z = mprintf("%s", g.argv[i]);
}
fossil_print("[%s] -> ", z);
file_simplify_name(z, -1, 0);
fossil_print("[%s]\n", z);
fossil_free(z);
}
}
|
| ︙ | ︙ |
Changes to src/patch.c.
| ︙ | ︙ | |||
667 668 669 670 671 672 673 |
Blob cmd;
FILE *f;
const char *zForce = (mFlags & PATCH_FORCE)!=0 ? " -f" : "";
if( g.argc!=4 ){
usage(mprintf("%s [USER@]HOST:DIRECTORY", zThisCmd));
}
zRemote = fossil_strdup(g.argv[3]);
| | < | | 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
Blob cmd;
FILE *f;
const char *zForce = (mFlags & PATCH_FORCE)!=0 ? " -f" : "";
if( g.argc!=4 ){
usage(mprintf("%s [USER@]HOST:DIRECTORY", zThisCmd));
}
zRemote = fossil_strdup(g.argv[3]);
zDir = (char*)file_skip_userhost(zRemote);
if( zDir==0 ){
zDir = zRemote;
blob_init(&cmd, 0, 0);
blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
blob_appendf(&cmd, " patch %s%s %$ -", zRemoteCmd, zForce, zDir);
}else{
Blob remote;
*(char*)(zDir-1) = 0;
transport_ssh_command(&cmd);
blob_append_escaped_arg(&cmd, zRemote, 0);
blob_init(&remote, 0, 0);
blob_appendf(&remote, "fossil patch %s%s --dir64 %z -",
zRemoteCmd, zForce, encode64(zDir, -1));
blob_append_escaped_arg(&cmd, blob_str(&remote), 0);
blob_reset(&remote);
|
| ︙ | ︙ |