bugGNU arch -- a revision control system - Bugs: bug #5640, buildcfg/cfgcat "valid...

 
 

bug #5640: buildcfg/cfgcat "valid name" tests trump "existing file" test

Submitted by:  Andrew Suffield <asuffield>
Submitted on:  Tue 30 Sep 2003 05:46:12 PM UTC  
 
Category: tlaSeverity: 3 - Normal
Item Group: small feature ideaStatus: None
Privacy: PublicOpen/Closed: Open
Release: lord@emf.net--2003b/tla--devo--1.1--patch-187
Fixed Release: 
Merge Request?: yes -- diffs included
Your Archive Name: 
Your Archive Location: 
Assigned to: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 30 Sep 2003 05:46:12 PM UTC, original submission:

tla cfgcat -s ../../configs/foo

This can't work, because the "valid name" test for configs rejects path components beginning with a period.

As discussed, the trivial fix is to skip the valid name test when it's a valid file. This also involves disabling some invariants which no longer hold.

For -o, I can see no use for the test (and it's been historically broken anyway), so I removed it.

--- orig/libarch/cmd-buildcfg.c
+++ mod/libarch/cmd-buildcfg.c
@@ -129,7 +129,7 @@

config = argv[1];

- if (!arch_valid_config_name (config))
+ if (safe_access (config, F_OK) != 0 && !arch_valid_config_name (config))
{
safe_printfmt (2, "%s: invalid config name (%s)\n",
argv[0], config);

--- orig/libarch/cmd-cfgcat.c
+++ mod/libarch/cmd-cfgcat.c
@@ -169,17 +169,17 @@

config = argv[1];

- if (!arch_valid_config_name (config))
+ if (safe_access (config, F_OK) != 0 && !arch_valid_config_name (config))
{
safe_printfmt (2, "%s: invalid config name (%s)\n", argv[0], config);
exit (2);
}

- if (output && !arch_valid_config_name (config))
- {
- safe_printfmt (2, "%s: invalid config name (%s)\n", argv[0], output);
- exit (2);
- }
+/* if (output && !arch_valid_config_name (output)) */
+/* { */
+/* safe_printfmt (2, "%s: invalid config name (%s)\n", argv[0], output); */
+/* exit (2); */
+/* } */

tree_root = arch_tree_root (0, dir, 0);

--- orig/libarch/configs.c
+++ mod/libarch/configs.c
@@ -38,14 +38,15 @@
t_uchar * rel = 0;
t_uchar * answer = 0;

- invariant (arch_valid_config_name (config_name));
-
-
rel = file_name_in_vicinity (0, "configs", config_name);
if (safe_access(rel, F_OK))
{
rel = file_name_in_vicinity (0, "", config_name);
}
+ else
+ {
+ invariant (arch_valid_config_name (config_name));
+ }
answer = file_name_in_vicinity (0, tree_root, rel);

lim_free (0, rel);
@@ -60,7 +61,7 @@
int in_fd;
rel_table answer = 0;

- invariant (arch_valid_config_name (config_name));
+/* invariant (arch_valid_config_name (config_name)); */

config_path = arch_config_path (tree_root, config_name);

@@ -215,7 +216,7 @@
t_uchar * config_tmp = 0;
int answer;

- invariant (arch_valid_config_name (name));
+/* invariant (arch_valid_config_name (name)); */

config_file = arch_config_path (tree_root, name);
config_dir = file_name_directory_file (0, config_file);
@@ -253,7 +254,7 @@
t_uchar * tmp_tail = 0;
t_uchar * config_tmp = 0;

- invariant (arch_valid_config_name (name));
+/* invariant (arch_valid_config_name (name)); */

config_file = arch_config_path (tree_root, name);
config_dir = file_name_directory_file (0, config_file);

Andrew Suffield <asuffield>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup1