Merge branch 'jk/unused-params'

Code clean-up.

* jk/unused-params:
  ref-filter: drop unused "sz" parameters
  ref-filter: drop unused "obj" parameters
  ref-filter: drop unused buf/sz pairs
  files-backend: drop refs parameter from split_symref_update()
  pack-objects: drop unused parameter from oe_map_new_pack()
  merge-recursive: drop several unused parameters
  diff: drop complete_rewrite parameter from run_external_diff()
  diff: drop unused emit data parameter from sane_truncate_line()
  diff: drop unused color reset parameters
  diff: drop options parameter from diffcore_fix_diff_index()
This commit is contained in:
Junio C Hamano
2019-03-07 09:59:56 +09:00
8 changed files with 45 additions and 59 deletions

View File

@ -531,7 +531,7 @@ int run_diff_index(struct rev_info *revs, int cached)
exit(128); exit(128);
diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/"); diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/");
diffcore_fix_diff_index(&revs->diffopt); diffcore_fix_diff_index();
diffcore_std(&revs->diffopt); diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt); diff_flush(&revs->diffopt);
trace_performance_leave("diff-index"); trace_performance_leave("diff-index");

31
diff.c
View File

@ -1614,8 +1614,7 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line
return ws_blank_line(line, len, ecbdata->ws_rule); return ws_blank_line(line, len, ecbdata->ws_rule);
} }
static void emit_add_line(const char *reset, static void emit_add_line(struct emit_callback *ecbdata,
struct emit_callback *ecbdata,
const char *line, int len) const char *line, int len)
{ {
unsigned flags = WSEH_NEW | ecbdata->ws_rule; unsigned flags = WSEH_NEW | ecbdata->ws_rule;
@ -1625,16 +1624,14 @@ static void emit_add_line(const char *reset,
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_PLUS, line, len, flags); emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_PLUS, line, len, flags);
} }
static void emit_del_line(const char *reset, static void emit_del_line(struct emit_callback *ecbdata,
struct emit_callback *ecbdata,
const char *line, int len) const char *line, int len)
{ {
unsigned flags = WSEH_OLD | ecbdata->ws_rule; unsigned flags = WSEH_OLD | ecbdata->ws_rule;
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_MINUS, line, len, flags); emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_MINUS, line, len, flags);
} }
static void emit_context_line(const char *reset, static void emit_context_line(struct emit_callback *ecbdata,
struct emit_callback *ecbdata,
const char *line, int len) const char *line, int len)
{ {
unsigned flags = WSEH_CONTEXT | ecbdata->ws_rule; unsigned flags = WSEH_CONTEXT | ecbdata->ws_rule;
@ -1743,7 +1740,6 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
int prefix, const char *data, int size) int prefix, const char *data, int size)
{ {
const char *endp = NULL; const char *endp = NULL;
const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);
while (0 < size) { while (0 < size) {
int len; int len;
@ -1752,10 +1748,10 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
len = endp ? (endp - data + 1) : size; len = endp ? (endp - data + 1) : size;
if (prefix != '+') { if (prefix != '+') {
ecb->lno_in_preimage++; ecb->lno_in_preimage++;
emit_del_line(reset, ecb, data, len); emit_del_line(ecb, data, len);
} else { } else {
ecb->lno_in_postimage++; ecb->lno_in_postimage++;
emit_add_line(reset, ecb, data, len); emit_add_line(ecb, data, len);
} }
size -= len; size -= len;
data += len; data += len;
@ -2292,7 +2288,7 @@ const char *diff_line_prefix(struct diff_options *opt)
return msgbuf->buf; return msgbuf->buf;
} }
static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len) static unsigned long sane_truncate_line(char *line, unsigned long len)
{ {
const char *cp; const char *cp;
unsigned long allot; unsigned long allot;
@ -2326,7 +2322,6 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)
static void fn_out_consume(void *priv, char *line, unsigned long len) static void fn_out_consume(void *priv, char *line, unsigned long len)
{ {
struct emit_callback *ecbdata = priv; struct emit_callback *ecbdata = priv;
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
struct diff_options *o = ecbdata->opt; struct diff_options *o = ecbdata->opt;
o->found_changes = 1; o->found_changes = 1;
@ -2357,7 +2352,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
if (line[0] == '@') { if (line[0] == '@') {
if (ecbdata->diff_words) if (ecbdata->diff_words)
diff_words_flush(ecbdata); diff_words_flush(ecbdata);
len = sane_truncate_line(ecbdata, line, len); len = sane_truncate_line(line, len);
find_lno(line, ecbdata); find_lno(line, ecbdata);
emit_hunk_header(ecbdata, line, len); emit_hunk_header(ecbdata, line, len);
return; return;
@ -2393,16 +2388,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
switch (line[0]) { switch (line[0]) {
case '+': case '+':
ecbdata->lno_in_postimage++; ecbdata->lno_in_postimage++;
emit_add_line(reset, ecbdata, line + 1, len - 1); emit_add_line(ecbdata, line + 1, len - 1);
break; break;
case '-': case '-':
ecbdata->lno_in_preimage++; ecbdata->lno_in_preimage++;
emit_del_line(reset, ecbdata, line + 1, len - 1); emit_del_line(ecbdata, line + 1, len - 1);
break; break;
case ' ': case ' ':
ecbdata->lno_in_postimage++; ecbdata->lno_in_postimage++;
ecbdata->lno_in_preimage++; ecbdata->lno_in_preimage++;
emit_context_line(reset, ecbdata, line + 1, len - 1); emit_context_line(ecbdata, line + 1, len - 1);
break; break;
default: default:
/* incomplete line at the end */ /* incomplete line at the end */
@ -4184,7 +4179,6 @@ static void run_external_diff(const char *pgm,
struct diff_filespec *one, struct diff_filespec *one,
struct diff_filespec *two, struct diff_filespec *two,
const char *xfrm_msg, const char *xfrm_msg,
int complete_rewrite,
struct diff_options *o) struct diff_options *o)
{ {
struct argv_array argv = ARGV_ARRAY_INIT; struct argv_array argv = ARGV_ARRAY_INIT;
@ -4342,8 +4336,7 @@ static void run_diff_cmd(const char *pgm,
} }
if (pgm) { if (pgm) {
run_external_diff(pgm, name, other, one, two, xfrm_msg, run_external_diff(pgm, name, other, one, two, xfrm_msg, o);
complete_rewrite, o);
return; return;
} }
if (one && two) if (one && two)
@ -6271,7 +6264,7 @@ static int diffnamecmp(const void *a_, const void *b_)
return strcmp(name_a, name_b); return strcmp(name_a, name_b);
} }
void diffcore_fix_diff_index(struct diff_options *options) void diffcore_fix_diff_index(void)
{ {
struct diff_queue_struct *q = &diff_queued_diff; struct diff_queue_struct *q = &diff_queued_diff;
QSORT(q->queue, q->nr, diffnamecmp); QSORT(q->queue, q->nr, diffnamecmp);

2
diff.h
View File

@ -370,7 +370,7 @@ int git_config_rename(const char *var, const char *value);
#define DIFF_PICKAXE_IGNORE_CASE 32 #define DIFF_PICKAXE_IGNORE_CASE 32
void diffcore_std(struct diff_options *); void diffcore_std(struct diff_options *);
void diffcore_fix_diff_index(struct diff_options *); void diffcore_fix_diff_index(void);
#define COMMON_DIFF_OPTIONS_HELP \ #define COMMON_DIFF_OPTIONS_HELP \
"\ncommon diff options:\n" \ "\ncommon diff options:\n" \

View File

@ -1402,8 +1402,7 @@ static int merge_mode_and_contents(struct merge_options *o,
static int handle_rename_via_dir(struct merge_options *o, static int handle_rename_via_dir(struct merge_options *o,
struct diff_filepair *pair, struct diff_filepair *pair,
const char *rename_branch, const char *rename_branch)
const char *other_branch)
{ {
/* /*
* Handle file adds that need to be renamed due to directory rename * Handle file adds that need to be renamed due to directory rename
@ -2213,8 +2212,7 @@ static void handle_directory_level_conflicts(struct merge_options *o,
remove_hashmap_entries(dir_re_merge, &remove_from_merge); remove_hashmap_entries(dir_re_merge, &remove_from_merge);
} }
static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs, static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs)
struct tree *tree)
{ {
struct hashmap *dir_renames; struct hashmap *dir_renames;
struct hashmap_iter iter; struct hashmap_iter iter;
@ -2460,8 +2458,7 @@ static void apply_directory_rename_modifications(struct merge_options *o,
struct tree *o_tree, struct tree *o_tree,
struct tree *a_tree, struct tree *a_tree,
struct tree *b_tree, struct tree *b_tree,
struct string_list *entries, struct string_list *entries)
int *clean)
{ {
struct string_list_item *item; struct string_list_item *item;
int stage = (tree == a_tree ? 2 : 3); int stage = (tree == a_tree ? 2 : 3);
@ -2632,8 +2629,7 @@ static struct string_list *get_renames(struct merge_options *o,
apply_directory_rename_modifications(o, pair, new_path, apply_directory_rename_modifications(o, pair, new_path,
re, tree, o_tree, re, tree, o_tree,
a_tree, b_tree, a_tree, b_tree,
entries, entries);
clean_merge);
} }
hashmap_iter_init(&collisions, &iter); hashmap_iter_init(&collisions, &iter);
@ -2944,8 +2940,8 @@ static int detect_and_process_renames(struct merge_options *o,
merge_pairs = get_diffpairs(o, common, merge); merge_pairs = get_diffpairs(o, common, merge);
if (o->detect_directory_renames) { if (o->detect_directory_renames) {
dir_re_head = get_directory_renames(head_pairs, head); dir_re_head = get_directory_renames(head_pairs);
dir_re_merge = get_directory_renames(merge_pairs, merge); dir_re_merge = get_directory_renames(merge_pairs);
handle_directory_level_conflicts(o, handle_directory_level_conflicts(o,
dir_re_head, head, dir_re_head, head,
@ -3268,8 +3264,7 @@ static int process_entry(struct merge_options *o,
clean_merge = 1; clean_merge = 1;
if (handle_rename_via_dir(o, if (handle_rename_via_dir(o,
conflict_info->pair1, conflict_info->pair1,
conflict_info->branch1, conflict_info->branch1))
conflict_info->branch2))
clean_merge = -1; clean_merge = -1;
break; break;
case RENAME_ADD: case RENAME_ADD:

View File

@ -119,8 +119,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)
* this fall back code, just stay simple and fall back to using * this fall back code, just stay simple and fall back to using
* in_pack[] array. * in_pack[] array.
*/ */
void oe_map_new_pack(struct packing_data *pack, void oe_map_new_pack(struct packing_data *pack)
struct packed_git *p)
{ {
uint32_t i; uint32_t i;

View File

@ -247,14 +247,14 @@ static inline struct packed_git *oe_in_pack(const struct packing_data *pack,
return pack->in_pack[e - pack->objects]; return pack->in_pack[e - pack->objects];
} }
void oe_map_new_pack(struct packing_data *pack, void oe_map_new_pack(struct packing_data *pack);
struct packed_git *p);
static inline void oe_set_in_pack(struct packing_data *pack, static inline void oe_set_in_pack(struct packing_data *pack,
struct object_entry *e, struct object_entry *e,
struct packed_git *p) struct packed_git *p)
{ {
if (!p->index) if (!p->index)
oe_map_new_pack(pack, p); oe_map_new_pack(pack);
if (pack->in_pack_by_idx) if (pack->in_pack_by_idx)
e->in_pack_idx = p->index; e->in_pack_idx = p->index;
else else

View File

@ -913,7 +913,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
} }
/* See grab_values */ /* See grab_values */
static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz) static void grab_tag_values(struct atom_value *val, int deref, struct object *obj)
{ {
int i; int i;
struct tag *tag = (struct tag *) obj; struct tag *tag = (struct tag *) obj;
@ -935,7 +935,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
} }
/* See grab_values */ /* See grab_values */
static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz) static void grab_commit_values(struct atom_value *val, int deref, struct object *obj)
{ {
int i; int i;
struct commit *commit = (struct commit *) obj; struct commit *commit = (struct commit *) obj;
@ -968,7 +968,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
} }
} }
static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz) static const char *find_wholine(const char *who, int wholen, const char *buf)
{ {
const char *eol; const char *eol;
while (*buf) { while (*buf) {
@ -1064,7 +1064,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
} }
/* See grab_values */ /* See grab_values */
static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz) static void grab_person(const char *who, struct atom_value *val, int deref, void *buf)
{ {
int i; int i;
int wholen = strlen(who); int wholen = strlen(who);
@ -1085,7 +1085,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
!starts_with(name + wholen, "date")) !starts_with(name + wholen, "date"))
continue; continue;
if (!wholine) if (!wholine)
wholine = find_wholine(who, wholen, buf, sz); wholine = find_wholine(who, wholen, buf);
if (!wholine) if (!wholine)
return; /* no point looking for it */ return; /* no point looking for it */
if (name[wholen] == 0) if (name[wholen] == 0)
@ -1105,7 +1105,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
if (strcmp(who, "tagger") && strcmp(who, "committer")) if (strcmp(who, "tagger") && strcmp(who, "committer"))
return; /* "author" for commit object is not wanted */ return; /* "author" for commit object is not wanted */
if (!wholine) if (!wholine)
wholine = find_wholine(who, wholen, buf, sz); wholine = find_wholine(who, wholen, buf);
if (!wholine) if (!wholine)
return; return;
for (i = 0; i < used_atom_cnt; i++) { for (i = 0; i < used_atom_cnt; i++) {
@ -1123,7 +1123,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
} }
} }
static void find_subpos(const char *buf, unsigned long sz, static void find_subpos(const char *buf,
const char **sub, unsigned long *sublen, const char **sub, unsigned long *sublen,
const char **body, unsigned long *bodylen, const char **body, unsigned long *bodylen,
unsigned long *nonsiglen, unsigned long *nonsiglen,
@ -1192,7 +1192,7 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size
} }
/* See grab_values */ /* See grab_values */
static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz) static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)
{ {
int i; int i;
const char *subpos = NULL, *bodypos = NULL, *sigpos = NULL; const char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;
@ -1212,7 +1212,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
!starts_with(name, "contents")) !starts_with(name, "contents"))
continue; continue;
if (!subpos) if (!subpos)
find_subpos(buf, sz, find_subpos(buf,
&subpos, &sublen, &subpos, &sublen,
&bodypos, &bodylen, &nonsiglen, &bodypos, &bodylen, &nonsiglen,
&sigpos, &siglen); &sigpos, &siglen);
@ -1265,19 +1265,19 @@ static void fill_missing_values(struct atom_value *val)
* pointed at by the ref itself; otherwise it is the object the * pointed at by the ref itself; otherwise it is the object the
* ref (which is a tag) refers to. * ref (which is a tag) refers to.
*/ */
static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz) static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf)
{ {
switch (obj->type) { switch (obj->type) {
case OBJ_TAG: case OBJ_TAG:
grab_tag_values(val, deref, obj, buf, sz); grab_tag_values(val, deref, obj);
grab_sub_body_contents(val, deref, obj, buf, sz); grab_sub_body_contents(val, deref, buf);
grab_person("tagger", val, deref, obj, buf, sz); grab_person("tagger", val, deref, buf);
break; break;
case OBJ_COMMIT: case OBJ_COMMIT:
grab_commit_values(val, deref, obj, buf, sz); grab_commit_values(val, deref, obj);
grab_sub_body_contents(val, deref, obj, buf, sz); grab_sub_body_contents(val, deref, buf);
grab_person("author", val, deref, obj, buf, sz); grab_person("author", val, deref, buf);
grab_person("committer", val, deref, obj, buf, sz); grab_person("committer", val, deref, buf);
break; break;
case OBJ_TREE: case OBJ_TREE:
/* grab_tree_values(val, deref, obj, buf, sz); */ /* grab_tree_values(val, deref, obj, buf, sz); */
@ -1516,7 +1516,7 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"), return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
oid_to_hex(&oi->oid), ref->refname); oid_to_hex(&oi->oid), ref->refname);
} }
grab_values(ref->value, deref, *obj, oi->content, oi->size); grab_values(ref->value, deref, *obj, oi->content);
} }
grab_common_values(ref->value, deref, oi); grab_common_values(ref->value, deref, oi);

View File

@ -2254,8 +2254,7 @@ static int split_head_update(struct ref_update *update,
* Note that the new update will itself be subject to splitting when * Note that the new update will itself be subject to splitting when
* the iteration gets to it. * the iteration gets to it.
*/ */
static int split_symref_update(struct files_ref_store *refs, static int split_symref_update(struct ref_update *update,
struct ref_update *update,
const char *referent, const char *referent,
struct ref_transaction *transaction, struct ref_transaction *transaction,
struct string_list *affected_refnames, struct string_list *affected_refnames,
@ -2449,7 +2448,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
* of processing the split-off update, so we * of processing the split-off update, so we
* don't have to do it here. * don't have to do it here.
*/ */
ret = split_symref_update(refs, update, ret = split_symref_update(update,
referent.buf, transaction, referent.buf, transaction,
affected_refnames, err); affected_refnames, err);
if (ret) if (ret)