Skip to content

Commit

Permalink
Use an enum for all SOTGV find_dir_tupid_dt_pg flags.
Browse files Browse the repository at this point in the history
This was originally just a 1 or 0 to create ghosts or not, but has since
expanded in meaning, making it a little harder to reason about.
  • Loading branch information
gittup committed Mar 18, 2024
1 parent 772afcb commit 7a40538
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/tup/create_name_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ tupid_t find_dir_tupid_dt_pg(tupid_t dt, struct pel_group *pg,
struct timespec mtime = {-1, 0};

/* Secret of the ghost valley! */
if(sotgv == 0) {
if(sotgv == SOTGV_NO_GHOST) {
return -1;
}
if(sotgv == SOTGV_CREATE_DIRS)
Expand Down
4 changes: 2 additions & 2 deletions src/tup/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int add_node_to_tree(tupid_t dt, const char *filename,
if(get_path_elements(filename, &pg) < 0)
return -1;

new_dt = find_dir_tupid_dt_pg(dt, &pg, &pel, 1, full_deps);
new_dt = find_dir_tupid_dt_pg(dt, &pg, &pel, SOTGV_CREATE_GHOSTS, full_deps);
if(new_dt < 0)
return -1;
if(new_dt == 0) {
Expand Down Expand Up @@ -739,7 +739,7 @@ static int update_write_info(FILE *f, tupid_t cmdid, struct file_info *info,
}

tent = NULL;
newdt = find_dir_tupid_dt_pg(DOT_DT, &pg, &pel, 0, 0);
newdt = find_dir_tupid_dt_pg(DOT_DT, &pg, &pel, SOTGV_NO_GHOST, 0);
del_pel_group(&pg);
if(newdt > 0) {
struct tup_entry *dtent;
Expand Down
8 changes: 6 additions & 2 deletions src/tup/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ struct tup_entry;
struct path_element;
struct pel_group;

#define SOTGV_CREATE_DIRS 2
#define SOTGV_IGNORE_DIRS 3
enum {
SOTGV_NO_GHOST,
SOTGV_CREATE_GHOSTS,
SOTGV_CREATE_DIRS,
SOTGV_IGNORE_DIRS,
};

int create_name_file(tupid_t dt, const char *file, struct timespec mtime,
struct tup_entry **entry);
Expand Down
4 changes: 2 additions & 2 deletions src/tup/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ int parser_include_file(struct tupfile *tf, const char *file)
fprintf(tf->f, "tup error: Unable to include file with hidden path element.\n");
goto out_del_pg;
}
newdt = find_dir_tupid_dt_pg(tf->curtent->tnode.tupid, &pg, &pel, 0, 0);
newdt = find_dir_tupid_dt_pg(tf->curtent->tnode.tupid, &pg, &pel, SOTGV_NO_GHOST, 0);
if(newdt <= 0) {
fprintf(tf->f, "tup error: Unable to find directory for include file '%s' relative to '", file);
print_tup_entry(tf->f, tf->curtent);
Expand Down Expand Up @@ -2473,7 +2473,7 @@ static int eval_path_list(struct tupfile *tf, struct path_list_head *plist, stru
static int path_list_fill_dt_pel(struct tupfile *tf, struct path_list *pl, tupid_t dt, int create_output_dirs)
{
struct pel_group pg;
int sotgv = 0;
int sotgv = SOTGV_NO_GHOST;

/* Bins get skipped. */
if(pl->bin)
Expand Down

0 comments on commit 7a40538

Please sign in to comment.