Skip to content

Commit ed6e803

Browse files
committed
pathspec: rename free_pathspec() to clear_pathspec()
The function takes a pointer to a pathspec structure, and releases the resources held by it, but does not free() the structure itself. Such a function should be called "clear", not "free". Signed-off-by: Junio C Hamano <[email protected]>
1 parent 60bd4b1 commit ed6e803

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int path_exists(struct tree *tree, const char *path)
322322
pathspec.recursive = 1;
323323
ret = read_tree_recursive(tree, "", 0, 0, &pathspec,
324324
reject_entry, &pathspec);
325-
free_pathspec(&pathspec);
325+
clear_pathspec(&pathspec);
326326
return ret != 0;
327327
}
328328

builtin/blame.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static struct origin *find_origin(struct scoreboard *sb,
609609
}
610610
}
611611
diff_flush(&diff_opts);
612-
free_pathspec(&diff_opts.pathspec);
612+
clear_pathspec(&diff_opts.pathspec);
613613
return porigin;
614614
}
615615

@@ -651,7 +651,7 @@ static struct origin *find_rename(struct scoreboard *sb,
651651
}
652652
}
653653
diff_flush(&diff_opts);
654-
free_pathspec(&diff_opts.pathspec);
654+
clear_pathspec(&diff_opts.pathspec);
655655
return porigin;
656656
}
657657

@@ -1343,7 +1343,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
13431343
} while (unblamed);
13441344
target->suspects = reverse_blame(leftover, NULL);
13451345
diff_flush(&diff_opts);
1346-
free_pathspec(&diff_opts.pathspec);
1346+
clear_pathspec(&diff_opts.pathspec);
13471347
}
13481348

13491349
/*

builtin/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int read_from_tree(const struct pathspec *pathspec,
158158
return 1;
159159
diffcore_std(&opt);
160160
diff_flush(&opt);
161-
free_pathspec(&opt.pathspec);
161+
clear_pathspec(&opt.pathspec);
162162

163163
return 0;
164164
}

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static int do_reupdate(int ac, const char **av,
759759
if (save_nr != active_nr)
760760
goto redo;
761761
}
762-
free_pathspec(&pathspec);
762+
clear_pathspec(&pathspec);
763763
return 0;
764764
}
765765

combine-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ void diff_tree_combined(const unsigned char *sha1,
15251525
free(tmp);
15261526
}
15271527

1528-
free_pathspec(&diffopts.pathspec);
1528+
clear_pathspec(&diffopts.pathspec);
15291529
}
15301530

15311531
void diff_tree_combined_merge(const struct commit *commit, int dense,

notes-merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
170170
sha1_to_hex(mp->remote));
171171
}
172172
diff_flush(&opt);
173-
free_pathspec(&opt.pathspec);
173+
clear_pathspec(&opt.pathspec);
174174

175175
*num_changes = len;
176176
return changes;
@@ -256,7 +256,7 @@ static void diff_tree_local(struct notes_merge_options *o,
256256
sha1_to_hex(mp->local));
257257
}
258258
diff_flush(&opt);
259-
free_pathspec(&opt.pathspec);
259+
clear_pathspec(&opt.pathspec);
260260
}
261261

262262
static void check_notes_merge_worktree(struct notes_merge_options *o)

pathspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
489489
sizeof(struct pathspec_item) * dst->nr);
490490
}
491491

492-
void free_pathspec(struct pathspec *pathspec)
492+
void clear_pathspec(struct pathspec *pathspec)
493493
{
494494
free(pathspec->items);
495495
pathspec->items = NULL;

pathspec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define PATHSPEC_ONESTAR 1 /* the pathspec pattern satisfies GFNM_ONESTAR */
2020

2121
struct pathspec {
22-
const char **_raw; /* get_pathspec() result, not freed by free_pathspec() */
22+
const char **_raw; /* get_pathspec() result, not freed by clear_pathspec() */
2323
int nr;
2424
unsigned int has_wildcard:1;
2525
unsigned int recursive:1;
@@ -74,7 +74,7 @@ extern void parse_pathspec(struct pathspec *pathspec,
7474
const char *prefix,
7575
const char **args);
7676
extern void copy_pathspec(struct pathspec *dst, const struct pathspec *src);
77-
extern void free_pathspec(struct pathspec *);
77+
extern void clear_pathspec(struct pathspec *);
7878

7979
static inline int ps_strncmp(const struct pathspec_item *item,
8080
const char *s1, const char *s2, size_t n)

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ static void prepare_show_merge(struct rev_info *revs)
14251425
ce_same_name(ce, active_cache[i+1]))
14261426
i++;
14271427
}
1428-
free_pathspec(&revs->prune_data);
1428+
clear_pathspec(&revs->prune_data);
14291429
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
14301430
PATHSPEC_PREFER_FULL | PATHSPEC_LITERAL_PATH, "", prune);
14311431
revs->limited = 1;

tree-diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static void try_to_follow_renames(const unsigned char *old, const unsigned char
607607
diff_setup_done(&diff_opts);
608608
ll_diff_tree_sha1(old, new, base, &diff_opts);
609609
diffcore_std(&diff_opts);
610-
free_pathspec(&diff_opts.pathspec);
610+
clear_pathspec(&diff_opts.pathspec);
611611

612612
/* Go through the new set of filepairing, and see if we find a more interesting one */
613613
opt->found_follow = 0;
@@ -630,7 +630,7 @@ static void try_to_follow_renames(const unsigned char *old, const unsigned char
630630
/* Update the path we use from now on.. */
631631
path[0] = p->one->path;
632632
path[1] = NULL;
633-
free_pathspec(&opt->pathspec);
633+
clear_pathspec(&opt->pathspec);
634634
parse_pathspec(&opt->pathspec,
635635
PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
636636
PATHSPEC_LITERAL_PATH, "", path);

0 commit comments

Comments
 (0)