Fossil SCM

On Unix, do not run the gmerge-command when the name of the file, as it is given to the command, holds a double quote, a dollar sign or a backquote. The names are put into the command as they are, so such a name reached the merge tool as several arguments or stopped the merge with an abort. The conflict is left marked in the file, with a warning.

dmestas 2026-11-14 16:37 UTC ssh-arg-quoting
Commit a3a13b16902dc8424dcb3d3adbd863824f41f75ea8519b8b60e9e01da32106b1
1 file changed +12
+12
--- src/merge3.c
+++ src/merge3.c
@@ -1195,10 +1195,22 @@
11951195
zOrig = file_newname(zV1, "original", 1);
11961196
blob_write_to_file(s.pV1, zOrig);
11971197
zOther = file_newname(zV1, "merge", 1);
11981198
blob_write_to_file(s.pV2, zOther);
11991199
if( rc>0 ){
1200
+#if !defined(_WIN32)
1201
+ if( zGMerge && zGMerge[0] && strpbrk(zPivot, "\"$`")!=0 ){
1202
+ /* The file names are put into the gmerge-command as they are,
1203
+ ** and the examples for that setting put double quotes around
1204
+ ** them. A name that holds one of these characters would not
1205
+ ** reach the command as one argument. zPivot stands for all
1206
+ ** four names, which differ only in their suffix. */
1207
+ fossil_warning("not running the gmerge-command on \"%s\" because "
1208
+ "the name holds a character that is special to "
1209
+ "the shell", zV1);
1210
+ }else
1211
+#endif
12001212
if( zGMerge && zGMerge[0] ){
12011213
char *zOut; /* Temporary output file */
12021214
char *zCmd; /* Command to invoke */
12031215
const char *azSubst[8]; /* Strings to be substituted */
12041216
zOut = file_newname(zV1, "output", 1);
12051217
--- src/merge3.c
+++ src/merge3.c
@@ -1195,10 +1195,22 @@
1195 zOrig = file_newname(zV1, "original", 1);
1196 blob_write_to_file(s.pV1, zOrig);
1197 zOther = file_newname(zV1, "merge", 1);
1198 blob_write_to_file(s.pV2, zOther);
1199 if( rc>0 ){
 
 
 
 
 
 
 
 
 
 
 
 
1200 if( zGMerge && zGMerge[0] ){
1201 char *zOut; /* Temporary output file */
1202 char *zCmd; /* Command to invoke */
1203 const char *azSubst[8]; /* Strings to be substituted */
1204 zOut = file_newname(zV1, "output", 1);
1205
--- src/merge3.c
+++ src/merge3.c
@@ -1195,10 +1195,22 @@
1195 zOrig = file_newname(zV1, "original", 1);
1196 blob_write_to_file(s.pV1, zOrig);
1197 zOther = file_newname(zV1, "merge", 1);
1198 blob_write_to_file(s.pV2, zOther);
1199 if( rc>0 ){
1200 #if !defined(_WIN32)
1201 if( zGMerge && zGMerge[0] && strpbrk(zPivot, "\"$`")!=0 ){
1202 /* The file names are put into the gmerge-command as they are,
1203 ** and the examples for that setting put double quotes around
1204 ** them. A name that holds one of these characters would not
1205 ** reach the command as one argument. zPivot stands for all
1206 ** four names, which differ only in their suffix. */
1207 fossil_warning("not running the gmerge-command on \"%s\" because "
1208 "the name holds a character that is special to "
1209 "the shell", zV1);
1210 }else
1211 #endif
1212 if( zGMerge && zGMerge[0] ){
1213 char *zOut; /* Temporary output file */
1214 char *zCmd; /* Command to invoke */
1215 const char *azSubst[8]; /* Strings to be substituted */
1216 zOut = file_newname(zV1, "output", 1);
1217

Keyboard Shortcuts

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