Merge branch 'bw/c-plus-plus'

Avoid using identifiers that clash with C++ keywords.  Even though
it is not a goal to compile Git with C++ compilers, changes like
this help use of code analysis tools that targets C++ on our
codebase.

* bw/c-plus-plus: (37 commits)
  replace: rename 'new' variables
  trailer: rename 'template' variables
  tempfile: rename 'template' variables
  wrapper: rename 'template' variables
  environment: rename 'namespace' variables
  diff: rename 'template' variables
  environment: rename 'template' variables
  init-db: rename 'template' variables
  unpack-trees: rename 'new' variables
  trailer: rename 'new' variables
  submodule: rename 'new' variables
  split-index: rename 'new' variables
  remote: rename 'new' variables
  ref-filter: rename 'new' variables
  read-cache: rename 'new' variables
  line-log: rename 'new' variables
  imap-send: rename 'new' variables
  http: rename 'new' variables
  entry: rename 'new' variables
  diffcore-delta: rename 'new' variables
  ...
This commit is contained in:
Junio C Hamano 2018-03-06 14:54:07 -08:00
commit 169c9c0169
63 changed files with 663 additions and 662 deletions

122
apply.c
View File

@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage,
size_t len, size_t postlen)
{
int i, ctx, reduced;
char *new, *old, *fixed;
char *new_buf, *old_buf, *fixed;
struct image fixed_preimage;
/*
@ -2327,25 +2327,25 @@ static void update_pre_post_images(struct image *preimage,
* We trust the caller to tell us if the update can be done
* in place (postlen==0) or not.
*/
old = postimage->buf;
old_buf = postimage->buf;
if (postlen)
new = postimage->buf = xmalloc(postlen);
new_buf = postimage->buf = xmalloc(postlen);
else
new = old;
new_buf = old_buf;
fixed = preimage->buf;
for (i = reduced = ctx = 0; i < postimage->nr; i++) {
size_t l_len = postimage->line[i].len;
if (!(postimage->line[i].flag & LINE_COMMON)) {
/* an added line -- no counterparts in preimage */
memmove(new, old, l_len);
old += l_len;
new += l_len;
memmove(new_buf, old_buf, l_len);
old_buf += l_len;
new_buf += l_len;
continue;
}
/* a common context -- skip it in the original postimage */
old += l_len;
old_buf += l_len;
/* and find the corresponding one in the fixed preimage */
while (ctx < preimage->nr &&
@ -2365,29 +2365,29 @@ static void update_pre_post_images(struct image *preimage,
/* and copy it in, while fixing the line length */
l_len = preimage->line[ctx].len;
memcpy(new, fixed, l_len);
new += l_len;
memcpy(new_buf, fixed, l_len);
new_buf += l_len;
fixed += l_len;
postimage->line[i].len = l_len;
ctx++;
}
if (postlen
? postlen < new - postimage->buf
: postimage->len < new - postimage->buf)
? postlen < new_buf - postimage->buf
: postimage->len < new_buf - postimage->buf)
die("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d",
(int)postlen, (int) postimage->len, (int)(new - postimage->buf));
(int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));
/* Fix the length of the whole thing */
postimage->len = new - postimage->buf;
postimage->len = new_buf - postimage->buf;
postimage->nr -= reduced;
}
static int line_by_line_fuzzy_match(struct image *img,
struct image *preimage,
struct image *postimage,
unsigned long try,
int try_lno,
unsigned long current,
int current_lno,
int preimage_limit)
{
int i;
@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,
for (i = 0; i < preimage_limit; i++) {
size_t prelen = preimage->line[i].len;
size_t imglen = img->line[try_lno+i].len;
size_t imglen = img->line[current_lno+i].len;
if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
if (!fuzzy_matchlines(img->buf + current + imgoff, imglen,
preimage->buf + preoff, prelen))
return 0;
if (preimage->line[i].flag & LINE_COMMON)
@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,
*/
extra_chars = preimage_end - preimage_eof;
strbuf_init(&fixed, imgoff + extra_chars);
strbuf_add(&fixed, img->buf + try, imgoff);
strbuf_add(&fixed, img->buf + current, imgoff);
strbuf_add(&fixed, preimage_eof, extra_chars);
fixed_buf = strbuf_detach(&fixed, &fixed_len);
update_pre_post_images(preimage, postimage,
@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,
struct image *img,
struct image *preimage,
struct image *postimage,
unsigned long try,
int try_lno,
unsigned long current,
int current_lno,
unsigned ws_rule,
int match_beginning, int match_end)
{
@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,
size_t fixed_len, postlen;
int preimage_limit;
if (preimage->nr + try_lno <= img->nr) {
if (preimage->nr + current_lno <= img->nr) {
/*
* The hunk falls within the boundaries of img.
*/
preimage_limit = preimage->nr;
if (match_end && (preimage->nr + try_lno != img->nr))
if (match_end && (preimage->nr + current_lno != img->nr))
return 0;
} else if (state->ws_error_action == correct_ws_error &&
(ws_rule & WS_BLANK_AT_EOF)) {
@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,
* match with img, and the remainder of the preimage
* must be blank.
*/
preimage_limit = img->nr - try_lno;
preimage_limit = img->nr - current_lno;
} else {
/*
* The hunk extends beyond the end of the img and
@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,
return 0;
}
if (match_beginning && try_lno)
if (match_beginning && current_lno)
return 0;
/* Quick hash check */
for (i = 0; i < preimage_limit; i++)
if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
(preimage->line[i].hash != img->line[try_lno + i].hash))
if ((img->line[current_lno + i].flag & LINE_PATCHED) ||
(preimage->line[i].hash != img->line[current_lno + i].hash))
return 0;
if (preimage_limit == preimage->nr) {
/*
* Do we have an exact match? If we were told to match
* at the end, size must be exactly at try+fragsize,
* otherwise try+fragsize must be still within the preimage,
* at the end, size must be exactly at current+fragsize,
* otherwise current+fragsize must be still within the preimage,
* and either case, the old piece should match the preimage
* exactly.
*/
if ((match_end
? (try + preimage->len == img->len)
: (try + preimage->len <= img->len)) &&
!memcmp(img->buf + try, preimage->buf, preimage->len))
? (current + preimage->len == img->len)
: (current + preimage->len <= img->len)) &&
!memcmp(img->buf + current, preimage->buf, preimage->len))
return 1;
} else {
/*
@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,
*/
if (state->ws_ignore_action == ignore_ws_change)
return line_by_line_fuzzy_match(img, preimage, postimage,
try, try_lno, preimage_limit);
current, current_lno, preimage_limit);
if (state->ws_error_action != correct_ws_error)
return 0;
@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,
*/
strbuf_init(&fixed, preimage->len + 1);
orig = preimage->buf;
target = img->buf + try;
target = img->buf + current;
for (i = 0; i < preimage_limit; i++) {
size_t oldlen = preimage->line[i].len;
size_t tgtlen = img->line[try_lno + i].len;
size_t tgtlen = img->line[current_lno + i].len;
size_t fixstart = fixed.len;
struct strbuf tgtfix;
int match;
@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state,
int match_beginning, int match_end)
{
int i;
unsigned long backwards, forwards, try;
int backwards_lno, forwards_lno, try_lno;
unsigned long backwards, forwards, current;
int backwards_lno, forwards_lno, current_lno;
/*
* If match_beginning or match_end is specified, there is no
@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,
if ((size_t) line > img->nr)
line = img->nr;
try = 0;
current = 0;
for (i = 0; i < line; i++)
try += img->line[i].len;
current += img->line[i].len;
/*
* There's probably some smart way to do this, but I'll leave
* that to the smart and beautiful people. I'm simple and stupid.
*/
backwards = try;
backwards = current;
backwards_lno = line;
forwards = try;
forwards = current;
forwards_lno = line;
try_lno = line;
current_lno = line;
for (i = 0; ; i++) {
if (match_fragment(state, img, preimage, postimage,
try, try_lno, ws_rule,
current, current_lno, ws_rule,
match_beginning, match_end))
return try_lno;
return current_lno;
again:
if (backwards_lno == 0 && forwards_lno == img->nr)
@ -2718,8 +2718,8 @@ static int find_pos(struct apply_state *state,
}
backwards_lno--;
backwards -= img->line[backwards_lno].len;
try = backwards;
try_lno = backwards_lno;
current = backwards;
current_lno = backwards_lno;
} else {
if (forwards_lno == img->nr) {
i++;
@ -2727,8 +2727,8 @@ static int find_pos(struct apply_state *state,
}
forwards += img->line[forwards_lno].len;
forwards_lno++;
try = forwards;
try_lno = forwards_lno;
current = forwards;
current_lno = forwards_lno;
}
}
@ -4163,30 +4163,30 @@ static void show_mode_change(struct patch *p, int show_name)
static void show_rename_copy(struct patch *p)
{
const char *renamecopy = p->is_rename ? "rename" : "copy";
const char *old, *new;
const char *old_name, *new_name;
/* Find common prefix */
old = p->old_name;
new = p->new_name;
old_name = p->old_name;
new_name = p->new_name;
while (1) {
const char *slash_old, *slash_new;
slash_old = strchr(old, '/');
slash_new = strchr(new, '/');
slash_old = strchr(old_name, '/');
slash_new = strchr(new_name, '/');
if (!slash_old ||
!slash_new ||
slash_old - old != slash_new - new ||
memcmp(old, new, slash_new - new))
slash_old - old_name != slash_new - new_name ||
memcmp(old_name, new_name, slash_new - new_name))
break;
old = slash_old + 1;
new = slash_new + 1;
old_name = slash_old + 1;
new_name = slash_new + 1;
}
/* p->old_name thru old is the common prefix, and old and new
/* p->old_name thru old_name is the common prefix, and old_name and new_name
* through the end of names are renames
*/
if (old != p->old_name)
if (old_name != p->old_name)
printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
(int)(old - p->old_name), p->old_name,
old, new, p->score);
(int)(old_name - p->old_name), p->old_name,
old_name, new_name, p->score);
else
printf(" %s %s => %s (%d%%)\n", renamecopy,
p->old_name, p->new_name, p->score);

33
blame.c
View File

@ -998,28 +998,29 @@ unsigned blame_entry_score(struct blame_scoreboard *sb, struct blame_entry *e)
}
/*
* best_so_far[] and this[] are both a split of an existing blame_entry
* that passes blame to the parent. Maintain best_so_far the best split
* so far, by comparing this and best_so_far and copying this into
* best_so_far[] and potential[] are both a split of an existing blame_entry
* that passes blame to the parent. Maintain best_so_far the best split so
* far, by comparing potential and best_so_far and copying potential into
* bst_so_far as needed.
*/
static void copy_split_if_better(struct blame_scoreboard *sb,
struct blame_entry *best_so_far,
struct blame_entry *this)
struct blame_entry *potential)
{
int i;
if (!this[1].suspect)
if (!potential[1].suspect)
return;
if (best_so_far[1].suspect) {
if (blame_entry_score(sb, &this[1]) < blame_entry_score(sb, &best_so_far[1]))
if (blame_entry_score(sb, &potential[1]) <
blame_entry_score(sb, &best_so_far[1]))
return;
}
for (i = 0; i < 3; i++)
blame_origin_incref(this[i].suspect);
blame_origin_incref(potential[i].suspect);
decref_split(best_so_far);
memcpy(best_so_far, this, sizeof(struct blame_entry [3]));
memcpy(best_so_far, potential, sizeof(struct blame_entry[3]));
}
/*
@ -1046,12 +1047,12 @@ static void handle_split(struct blame_scoreboard *sb,
if (ent->num_lines <= tlno)
return;
if (tlno < same) {
struct blame_entry this[3];
struct blame_entry potential[3];
tlno += ent->s_lno;
same += ent->s_lno;
split_overlap(this, ent, tlno, plno, same, parent);
copy_split_if_better(sb, split, this);
decref_split(this);
split_overlap(potential, ent, tlno, plno, same, parent);
copy_split_if_better(sb, split, potential);
decref_split(potential);
}
}
@ -1273,7 +1274,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
struct diff_filepair *p = diff_queued_diff.queue[i];
struct blame_origin *norigin;
mmfile_t file_p;
struct blame_entry this[3];
struct blame_entry potential[3];
if (!DIFF_FILE_VALID(p->one))
continue; /* does not exist in parent */
@ -1292,10 +1293,10 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
for (j = 0; j < num_ents; j++) {
find_copy_in_blob(sb, blame_list[j].ent,
norigin, this, &file_p);
norigin, potential, &file_p);
copy_split_if_better(sb, blame_list[j].split,
this);
decref_split(this);
potential);
decref_split(potential);
}
blame_origin_decref(norigin);
}

View File

@ -76,7 +76,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
buf = NULL;
switch (opt) {
case 't':
oi.typename = &sb;
oi.type_name = &sb;
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
die("git cat-file: could not get object info");
if (sb.len) {
@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
if (data->mark_query)
data->info.typep = &data->type;
else
strbuf_addstr(sb, typename(data->type));
strbuf_addstr(sb, type_name(data->type));
} else if (is_atom("objectsize", atom, len)) {
if (data->mark_query)
data->info.sizep = &data->size;

View File

@ -54,14 +54,14 @@ struct checkout_opts {
struct tree *source_tree;
};
static int post_checkout_hook(struct commit *old, struct commit *new,
static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
int changed)
{
return run_hook_le(NULL, "post-checkout",
oid_to_hex(old ? &old->object.oid : &null_oid),
oid_to_hex(new ? &new->object.oid : &null_oid),
oid_to_hex(old_commit ? &old_commit->object.oid : &null_oid),
oid_to_hex(new_commit ? &new_commit->object.oid : &null_oid),
changed ? "1" : "0", NULL);
/* "new" can be NULL when checking out from the index before
/* "new_commit" can be NULL when checking out from the index before
a commit exists. */
}
@ -471,8 +471,8 @@ static void setup_branch_path(struct branch_info *branch)
}
static int merge_working_tree(const struct checkout_opts *opts,
struct branch_info *old,
struct branch_info *new,
struct branch_info *old_branch_info,
struct branch_info *new_branch_info,
int *writeout_error)
{
int ret;
@ -484,7 +484,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
resolve_undo_clear();
if (opts->force) {
ret = reset_tree(new->commit->tree, opts, 1, writeout_error);
ret = reset_tree(new_branch_info->commit->tree, opts, 1, writeout_error);
if (ret)
return ret;
} else {
@ -510,7 +510,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
topts.initial_checkout = is_cache_unborn();
topts.update = 1;
topts.merge = 1;
topts.gently = opts->merge && old->commit;
topts.gently = opts->merge && old_branch_info->commit;
topts.verbose_update = opts->show_progress;
topts.fn = twoway_merge;
if (opts->overwrite_ignore) {
@ -518,11 +518,11 @@ static int merge_working_tree(const struct checkout_opts *opts,
topts.dir->flags |= DIR_SHOW_IGNORED;
setup_standard_excludes(topts.dir);
}
tree = parse_tree_indirect(old->commit ?
&old->commit->object.oid :
tree = parse_tree_indirect(old_branch_info->commit ?
&old_branch_info->commit->object.oid :
the_hash_algo->empty_tree);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(&new->commit->object.oid);
tree = parse_tree_indirect(&new_branch_info->commit->object.oid);
init_tree_desc(&trees[1], tree->buffer, tree->size);
ret = unpack_trees(2, trees, &topts);
@ -539,10 +539,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
return 1;
/*
* Without old->commit, the below is the same as
* Without old_branch_info->commit, the below is the same as
* the two-tree unpack we already tried and failed.
*/
if (!old->commit)
if (!old_branch_info->commit)
return 1;
/* Do more real merge */
@ -570,18 +570,18 @@ static int merge_working_tree(const struct checkout_opts *opts,
o.verbosity = 0;
work = write_tree_from_memory(&o);
ret = reset_tree(new->commit->tree, opts, 1,
ret = reset_tree(new_branch_info->commit->tree, opts, 1,
writeout_error);
if (ret)
return ret;
o.ancestor = old->name;
o.branch1 = new->name;
o.ancestor = old_branch_info->name;
o.branch1 = new_branch_info->name;
o.branch2 = "local";
ret = merge_trees(&o, new->commit->tree, work,
old->commit->tree, &result);
ret = merge_trees(&o, new_branch_info->commit->tree, work,
old_branch_info->commit->tree, &result);
if (ret < 0)
exit(128);
ret = reset_tree(new->commit->tree, opts, 0,
ret = reset_tree(new_branch_info->commit->tree, opts, 0,
writeout_error);
strbuf_release(&o.obuf);
if (ret)
@ -599,15 +599,15 @@ static int merge_working_tree(const struct checkout_opts *opts,
die(_("unable to write new index file"));
if (!opts->force && !opts->quiet)
show_local_changes(&new->commit->object, &opts->diff_options);
show_local_changes(&new_branch_info->commit->object, &opts->diff_options);
return 0;
}
static void report_tracking(struct branch_info *new)
static void report_tracking(struct branch_info *new_branch_info)
{
struct strbuf sb = STRBUF_INIT;
struct branch *branch = branch_get(new->name);
struct branch *branch = branch_get(new_branch_info->name);
if (!format_tracking_info(branch, &sb))
return;
@ -616,8 +616,8 @@ static void report_tracking(struct branch_info *new)
}
static void update_refs_for_switch(const struct checkout_opts *opts,
struct branch_info *old,
struct branch_info *new)
struct branch_info *old_branch_info,
struct branch_info *new_branch_info)
{
struct strbuf msg = STRBUF_INIT;
const char *old_desc, *reflog_msg;
@ -644,69 +644,69 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
free(refname);
}
else
create_branch(opts->new_branch, new->name,
create_branch(opts->new_branch, new_branch_info->name,
opts->new_branch_force ? 1 : 0,
opts->new_branch_force ? 1 : 0,
opts->new_branch_log,
opts->quiet,
opts->track);
new->name = opts->new_branch;
setup_branch_path(new);
new_branch_info->name = opts->new_branch;
setup_branch_path(new_branch_info);
}
old_desc = old->name;
if (!old_desc && old->commit)
old_desc = oid_to_hex(&old->commit->object.oid);
old_desc = old_branch_info->name;
if (!old_desc && old_branch_info->commit)
old_desc = oid_to_hex(&old_branch_info->commit->object.oid);
reflog_msg = getenv("GIT_REFLOG_ACTION");
if (!reflog_msg)
strbuf_addf(&msg, "checkout: moving from %s to %s",
old_desc ? old_desc : "(invalid)", new->name);
old_desc ? old_desc : "(invalid)", new_branch_info->name);
else
strbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
if (!strcmp(new_branch_info->name, "HEAD") && !new_branch_info->path && !opts->force_detach) {
/* Nothing to do. */
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
update_ref(msg.buf, "HEAD", &new->commit->object.oid, NULL,
} else if (opts->force_detach || !new_branch_info->path) { /* No longer on any branch. */
update_ref(msg.buf, "HEAD", &new_branch_info->commit->object.oid, NULL,
REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);
if (!opts->quiet) {
if (old->path &&
if (old_branch_info->path &&
advice_detached_head && !opts->force_detach)
detach_advice(new->name);
describe_detached_head(_("HEAD is now at"), new->commit);
detach_advice(new_branch_info->name);
describe_detached_head(_("HEAD is now at"), new_branch_info->commit);
}
} else if (new->path) { /* Switch branches. */
if (create_symref("HEAD", new->path, msg.buf) < 0)
} else if (new_branch_info->path) { /* Switch branches. */
if (create_symref("HEAD", new_branch_info->path, msg.buf) < 0)
die(_("unable to update HEAD"));
if (!opts->quiet) {
if (old->path && !strcmp(new->path, old->path)) {
if (old_branch_info->path && !strcmp(new_branch_info->path, old_branch_info->path)) {
if (opts->new_branch_force)
fprintf(stderr, _("Reset branch '%s'\n"),
new->name);
new_branch_info->name);
else
fprintf(stderr, _("Already on '%s'\n"),
new->name);
new_branch_info->name);
} else if (opts->new_branch) {
if (opts->branch_exists)
fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name);
fprintf(stderr, _("Switched to and reset branch '%s'\n"), new_branch_info->name);
else
fprintf(stderr, _("Switched to a new branch '%s'\n"), new->name);
fprintf(stderr, _("Switched to a new branch '%s'\n"), new_branch_info->name);
} else {
fprintf(stderr, _("Switched to branch '%s'\n"),
new->name);
new_branch_info->name);
}
}
if (old->path && old->name) {
if (!ref_exists(old->path) && reflog_exists(old->path))
delete_reflog(old->path);
if (old_branch_info->path && old_branch_info->name) {
if (!ref_exists(old_branch_info->path) && reflog_exists(old_branch_info->path))
delete_reflog(old_branch_info->path);
}
}
remove_branch_state();
strbuf_release(&msg);
if (!opts->quiet &&
(new->path || (!opts->force_detach && !strcmp(new->name, "HEAD"))))
report_tracking(new);
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
report_tracking(new_branch_info);
}
static int add_pending_uninteresting_ref(const char *refname,
@ -786,10 +786,10 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
* HEAD. If it is not reachable from any ref, this is the last chance
* for the user to do so without resorting to reflog.
*/
static void orphaned_commit_warning(struct commit *old, struct commit *new)
static void orphaned_commit_warning(struct commit *old_commit, struct commit *new_commit)
{
struct rev_info revs;
struct object *object = &old->object;
struct object *object = &old_commit->object;
init_revisions(&revs, NULL);
setup_revisions(0, NULL, &revs, NULL);
@ -798,57 +798,57 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
add_pending_object(&revs, object, oid_to_hex(&object->oid));
for_each_ref(add_pending_uninteresting_ref, &revs);
add_pending_oid(&revs, "HEAD", &new->object.oid, UNINTERESTING);
add_pending_oid(&revs, "HEAD", &new_commit->object.oid, UNINTERESTING);
if (prepare_revision_walk(&revs))
die(_("internal error in revision walk"));
if (!(old->object.flags & UNINTERESTING))
suggest_reattach(old, &revs);
if (!(old_commit->object.flags & UNINTERESTING))
suggest_reattach(old_commit, &revs);
else
describe_detached_head(_("Previous HEAD position was"), old);
describe_detached_head(_("Previous HEAD position was"), old_commit);
/* Clean up objects used, as they will be reused. */
clear_commit_marks_all(ALL_REV_FLAGS);
}
static int switch_branches(const struct checkout_opts *opts,
struct branch_info *new)
struct branch_info *new_branch_info)
{
int ret = 0;
struct branch_info old;
struct branch_info old_branch_info;
void *path_to_free;
struct object_id rev;
int flag, writeout_error = 0;
memset(&old, 0, sizeof(old));
old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
if (old.path)
old.commit = lookup_commit_reference_gently(&rev, 1);
memset(&old_branch_info, 0, sizeof(old_branch_info));
old_branch_info.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
if (old_branch_info.path)
old_branch_info.commit = lookup_commit_reference_gently(&rev, 1);
if (!(flag & REF_ISSYMREF))
old.path = NULL;
old_branch_info.path = NULL;
if (old.path)
skip_prefix(old.path, "refs/heads/", &old.name);
if (old_branch_info.path)
skip_prefix(old_branch_info.path, "refs/heads/", &old_branch_info.name);
if (!new->name) {
new->name = "HEAD";
new->commit = old.commit;
if (!new->commit)
if (!new_branch_info->name) {
new_branch_info->name = "HEAD";
new_branch_info->commit = old_branch_info.commit;
if (!new_branch_info->commit)
die(_("You are on a branch yet to be born"));
parse_commit_or_die(new->commit);
parse_commit_or_die(new_branch_info->commit);
}
ret = merge_working_tree(opts, &old, new, &writeout_error);
ret = merge_working_tree(opts, &old_branch_info, new_branch_info, &writeout_error);
if (ret) {
free(path_to_free);
return ret;
}
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
orphaned_commit_warning(old.commit, new->commit);
if (!opts->quiet && !old_branch_info.path && old_branch_info.commit && new_branch_info->commit != old_branch_info.commit)
orphaned_commit_warning(old_branch_info.commit, new_branch_info->commit);
update_refs_for_switch(opts, &old, new);
update_refs_for_switch(opts, &old_branch_info, new_branch_info);
ret = post_checkout_hook(old.commit, new->commit, 1);
ret = post_checkout_hook(old_branch_info.commit, new_branch_info->commit, 1);
free(path_to_free);
return ret || writeout_error;
}
@ -869,7 +869,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
static int parse_branchname_arg(int argc, const char **argv,
int dwim_new_local_branch_ok,
struct branch_info *new,
struct branch_info *new_branch_info,
struct checkout_opts *opts,
struct object_id *rev)
{
@ -987,22 +987,22 @@ static int parse_branchname_arg(int argc, const char **argv,
argv++;
argc--;
new->name = arg;
setup_branch_path(new);
new_branch_info->name = arg;
setup_branch_path(new_branch_info);
if (!check_refname_format(new->path, 0) &&
!read_ref(new->path, &branch_rev))
if (!check_refname_format(new_branch_info->path, 0) &&
!read_ref(new_branch_info->path, &branch_rev))
oidcpy(rev, &branch_rev);
else
new->path = NULL; /* not an existing branch */
new_branch_info->path = NULL; /* not an existing branch */
new->commit = lookup_commit_reference_gently(rev, 1);
if (!new->commit) {
new_branch_info->commit = lookup_commit_reference_gently(rev, 1);
if (!new_branch_info->commit) {
/* not a commit */
*source_tree = parse_tree_indirect(rev);
} else {
parse_commit_or_die(new->commit);
*source_tree = new->commit->tree;
parse_commit_or_die(new_branch_info->commit);
*source_tree = new_branch_info->commit->tree;
}
if (!*source_tree) /* case (1): want a tree */
@ -1042,7 +1042,7 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
}
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new)
struct branch_info *new_branch_info)
{
if (opts->pathspec.nr)
die(_("paths cannot be used with switching branches"));
@ -1071,21 +1071,21 @@ static int checkout_branch(struct checkout_opts *opts,
} else if (opts->track == BRANCH_TRACK_UNSPECIFIED)
opts->track = git_branch_track;
if (new->name && !new->commit)
if (new_branch_info->name && !new_branch_info->commit)
die(_("Cannot switch branch to a non-commit '%s'"),
new->name);
new_branch_info->name);
if (new->path && !opts->force_detach && !opts->new_branch &&
if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
!opts->ignore_other_worktrees) {
int flag;
char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
if (head_ref &&
(!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)))
die_if_checked_out(new->path, 1);
(!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
die_if_checked_out(new_branch_info->path, 1);
free(head_ref);
}
if (!new->commit && opts->new_branch) {
if (!new_branch_info->commit && opts->new_branch) {
struct object_id rev;
int flag;
@ -1093,13 +1093,13 @@ static int checkout_branch(struct checkout_opts *opts,
(flag & REF_ISSYMREF) && is_null_oid(&rev))
return switch_unborn_to_new_branch(opts);
}
return switch_branches(opts, new);
return switch_branches(opts, new_branch_info);
}
int cmd_checkout(int argc, const char **argv, const char *prefix)
{
struct checkout_opts opts;
struct branch_info new;
struct branch_info new_branch_info;
char *conflict_style = NULL;
int dwim_new_local_branch = 1;
struct option options[] = {
@ -1137,7 +1137,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
};
memset(&opts, 0, sizeof(opts));
memset(&new, 0, sizeof(new));
memset(&new_branch_info, 0, sizeof(new_branch_info));
opts.overwrite_ignore = 1;
opts.prefix = prefix;
opts.show_progress = -1;
@ -1209,7 +1209,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
opts.track == BRANCH_TRACK_UNSPECIFIED &&
!opts.new_branch;
int n = parse_branchname_arg(argc, argv, dwim_ok,
&new, &opts, &rev);
&new_branch_info, &opts, &rev);
argv += n;
argc -= n;
}
@ -1252,7 +1252,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
UNLEAK(opts);
if (opts.patch_mode || opts.pathspec.nr)
return checkout_paths(&opts, new.name);
return checkout_paths(&opts, new_branch_info.name);
else
return checkout_branch(&opts, &new);
return checkout_branch(&opts, &new_branch_info);
}

View File

@ -76,7 +76,7 @@ static int diff_tree_stdin(char *line)
if (obj->type == OBJ_TREE)
return stdin_diff_trees((struct tree *)obj, p);
error("Object %s is a %s, not a commit or tree",
oid_to_hex(&oid), typename(obj->type));
oid_to_hex(&oid), type_name(obj->type));
return -1;
}

View File

@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid)
buf = read_sha1_file(oid->hash, &type, &size);
if (!buf)
die ("Could not read blob %s", oid_to_hex(oid));
if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0)
if (check_sha1_signature(oid->hash, buf, size, type_name(type)) < 0)
die("sha1 mismatch in blob %s", oid_to_hex(oid));
object = parse_object_buffer(oid, type, size, buf, &eaten);
}
@ -757,7 +757,7 @@ static void handle_tag(const char *name, struct tag *tag)
if (tagged->type != OBJ_COMMIT) {
die ("Tag %s tags unexported %s!",
oid_to_hex(&tag->object.oid),
typename(tagged->type));
type_name(tagged->type));
}
p = (struct commit *)tagged;
for (;;) {
@ -839,7 +839,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (!commit) {
warning("%s: Unexpected object of type %s, skipping.",
e->name,
typename(e->item->type));
type_name(e->item->type));
continue;
}
@ -851,7 +851,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
continue;
default: /* OBJ_TAG (nested tags) is already handled */
warning("Tag points to object of unexpected type %s, skipping.",
typename(commit->object.type));
type_name(commit->object.type));
continue;
}

View File

@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)
object_as_type(obj, type, 0);
}
ret = typename(obj->type);
ret = type_name(obj->type);
if (!ret)
ret = "unknown";
@ -137,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
printf("broken link from %7s %s\n",
printable_type(parent), describe_object(parent));
printf("broken link from %7s %s\n",
(type == OBJ_ANY ? "unknown" : typename(type)), "unknown");
(type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
errors_found |= ERROR_REACHABLE;
return 1;
}

View File

@ -627,7 +627,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
free(data);
return hit;
}
die(_("unable to grep from object of type %s"), typename(obj->type));
die(_("unable to grep from object of type %s"), type_name(obj->type));
}
static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,

View File

@ -194,11 +194,11 @@ static void do_add_man_viewer_info(const char *name,
size_t len,
const char *value)
{
struct man_viewer_info_list *new;
FLEX_ALLOC_MEM(new, name, name, len);
new->info = xstrdup(value);
new->next = man_viewer_info_list;
man_viewer_info_list = new;
struct man_viewer_info_list *new_man_viewer;
FLEX_ALLOC_MEM(new_man_viewer, name, name, len);
new_man_viewer->info = xstrdup(value);
new_man_viewer->next = man_viewer_info_list;
man_viewer_info_list = new_man_viewer;
}
static int add_man_viewer_path(const char *name,

View File

@ -228,7 +228,7 @@ static unsigned check_object(struct object *obj)
if (type != obj->type)
die(_("object %s: expected type %s, found %s"),
oid_to_hex(&obj->oid),
typename(obj->type), typename(type));
type_name(obj->type), type_name(type));
obj->flags |= FLAG_CHECKED;
return 1;
}
@ -448,7 +448,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
int hdrlen;
if (!is_delta_type(type)) {
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), size) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), size) + 1;
the_hash_algo->init_fn(&c);
the_hash_algo->update_fn(&c, hdr, hdrlen);
} else
@ -849,7 +849,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
obj = parse_object_buffer(oid, type, size, buf,
&eaten);
if (!obj)
die(_("invalid %s"), typename(type));
die(_("invalid %s"), type_name(type));
if (do_fsck_object &&
fsck_object(obj, buf, size, &fsck_options))
die(_("Error in object"));
@ -959,7 +959,7 @@ static void resolve_delta(struct object_entry *delta_obj,
if (!result->data)
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
hash_object_file(result->data, result->size,
typename(delta_obj->real_type), &delta_obj->idx.oid);
type_name(delta_obj->real_type), &delta_obj->idx.oid);
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
&delta_obj->idx.oid);
counter_lock();
@ -1378,7 +1378,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
continue;
if (check_sha1_signature(d->sha1, base_obj->data,
base_obj->size, typename(type)))
base_obj->size, type_name(type)))
die(_("local object %s is corrupt"), sha1_to_hex(d->sha1));
base_obj->obj = append_obj_to_pack(f, d->sha1,
base_obj->data, base_obj->size, type);
@ -1615,7 +1615,7 @@ static void show_pack_info(int stat_only)
continue;
printf("%s %-6s %lu %lu %"PRIuMAX,
oid_to_hex(&obj->idx.oid),
typename(obj->real_type), obj->size,
type_name(obj->real_type), obj->size,
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
(uintmax_t)obj->idx.offset);
if (is_delta_type(obj->type)) {

View File

@ -24,11 +24,11 @@ static int init_is_bare_repository = 0;
static int init_shared_repository = -1;
static const char *init_db_template_dir;
static void copy_templates_1(struct strbuf *path, struct strbuf *template,
static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
DIR *dir)
{
size_t path_baselen = path->len;
size_t template_baselen = template->len;
size_t template_baselen = template_path->len;
struct dirent *de;
/* Note: if ".git/hooks" file exists in the repository being
@ -44,12 +44,12 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,
int exists = 0;
strbuf_setlen(path, path_baselen);
strbuf_setlen(template, template_baselen);
strbuf_setlen(template_path, template_baselen);
if (de->d_name[0] == '.')
continue;
strbuf_addstr(path, de->d_name);
strbuf_addstr(template, de->d_name);
strbuf_addstr(template_path, de->d_name);
if (lstat(path->buf, &st_git)) {
if (errno != ENOENT)
die_errno(_("cannot stat '%s'"), path->buf);
@ -57,36 +57,36 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,
else
exists = 1;
if (lstat(template->buf, &st_template))
die_errno(_("cannot stat template '%s'"), template->buf);
if (lstat(template_path->buf, &st_template))
die_errno(_("cannot stat template '%s'"), template_path->buf);
if (S_ISDIR(st_template.st_mode)) {
DIR *subdir = opendir(template->buf);
DIR *subdir = opendir(template_path->buf);
if (!subdir)
die_errno(_("cannot opendir '%s'"), template->buf);
die_errno(_("cannot opendir '%s'"), template_path->buf);
strbuf_addch(path, '/');
strbuf_addch(template, '/');
copy_templates_1(path, template, subdir);
strbuf_addch(template_path, '/');
copy_templates_1(path, template_path, subdir);
closedir(subdir);
}
else if (exists)
continue;
else if (S_ISLNK(st_template.st_mode)) {
struct strbuf lnk = STRBUF_INIT;
if (strbuf_readlink(&lnk, template->buf, 0) < 0)
die_errno(_("cannot readlink '%s'"), template->buf);
if (strbuf_readlink(&lnk, template_path->buf, 0) < 0)
die_errno(_("cannot readlink '%s'"), template_path->buf);
if (symlink(lnk.buf, path->buf))
die_errno(_("cannot symlink '%s' '%s'"),
lnk.buf, path->buf);
strbuf_release(&lnk);
}
else if (S_ISREG(st_template.st_mode)) {
if (copy_file(path->buf, template->buf, st_template.st_mode))
if (copy_file(path->buf, template_path->buf, st_template.st_mode))
die_errno(_("cannot copy '%s' to '%s'"),
template->buf, path->buf);
template_path->buf, path->buf);
}
else
error(_("ignoring template %s"), template->buf);
error(_("ignoring template %s"), template_path->buf);
}
}

View File

@ -521,7 +521,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
strbuf_addf(msg, "%s\t\t%s '%s'\n",
oid_to_hex(&desc->obj->oid),
typename(desc->obj->type),
type_name(desc->obj->type),
remote);
goto cleanup;
}

View File

@ -112,7 +112,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
mode_type = object_type(mode);
if (mode_type != type_from_string(ptr)) {
die("entry '%s' object type (%s) doesn't match mode type (%s)",
path, ptr, typename(mode_type));
path, ptr, type_name(mode_type));
}
/* Check the type of object identified by sha1 */
@ -131,7 +131,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
* because the new tree entry will never be correct.
*/
die("entry '%s' object %s is a %s but specified type was (%s)",
path, sha1_to_hex(sha1), typename(obj_type), typename(mode_type));
path, sha1_to_hex(sha1), type_name(obj_type), type_name(mode_type));
}
}

View File

@ -1379,10 +1379,10 @@ static void cleanup_preferred_base(void)
it = pbase_tree;
pbase_tree = NULL;
while (it) {
struct pbase_tree *this = it;
it = this->next;
free(this->pcache.tree_data);
free(this);
struct pbase_tree *tmp = it;
it = tmp->next;
free(tmp->pcache.tree_data);
free(tmp);
}
for (i = 0; i < ARRAY_SIZE(pbase_tree_cache); i++) {

View File

@ -48,17 +48,17 @@ static inline void llist_item_put(struct llist_item *item)
static inline struct llist_item *llist_item_get(void)
{
struct llist_item *new;
struct llist_item *new_item;
if ( free_nodes ) {
new = free_nodes;
new_item = free_nodes;
free_nodes = free_nodes->next;
} else {
int i = 1;
ALLOC_ARRAY(new, BLKSIZE);
ALLOC_ARRAY(new_item, BLKSIZE);
for (; i < BLKSIZE; i++)
llist_item_put(&new[i]);
llist_item_put(&new_item[i]);
}
return new;
return new_item;
}
static void llist_free(struct llist *list)
@ -80,26 +80,26 @@ static inline void llist_init(struct llist **list)
static struct llist * llist_copy(struct llist *list)
{
struct llist *ret;
struct llist_item *new, *old, *prev;
struct llist_item *new_item, *old_item, *prev;
llist_init(&ret);
if ((ret->size = list->size) == 0)
return ret;
new = ret->front = llist_item_get();
new->sha1 = list->front->sha1;
new_item = ret->front = llist_item_get();
new_item->sha1 = list->front->sha1;
old = list->front->next;
while (old) {
prev = new;
new = llist_item_get();
prev->next = new;
new->sha1 = old->sha1;
old = old->next;
old_item = list->front->next;
while (old_item) {
prev = new_item;
new_item = llist_item_get();
prev->next = new_item;
new_item->sha1 = old_item->sha1;
old_item = old_item->next;
}
new->next = NULL;
ret->back = new;
new_item->next = NULL;
ret->back = new_item;
return ret;
}
@ -108,24 +108,24 @@ static inline struct llist_item *llist_insert(struct llist *list,
struct llist_item *after,
const unsigned char *sha1)
{
struct llist_item *new = llist_item_get();
new->sha1 = sha1;
new->next = NULL;
struct llist_item *new_item = llist_item_get();
new_item->sha1 = sha1;
new_item->next = NULL;
if (after != NULL) {
new->next = after->next;
after->next = new;
new_item->next = after->next;
after->next = new_item;
if (after == list->back)
list->back = new;
list->back = new_item;
} else {/* insert in front */
if (list->size == 0)
list->back = new;
list->back = new_item;
else
new->next = list->front;
list->front = new;
new_item->next = list->front;
list->front = new_item;
}
list->size++;
return new;
return new_item;
}
static inline struct llist_item *llist_insert_back(struct llist *list,

View File

@ -52,7 +52,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
if (show_only || verbose) {
enum object_type type = sha1_object_info(oid->hash, NULL);
printf("%s %s\n", oid_to_hex(oid),
(type > 0) ? typename(type) : "unknown");
(type > 0) ? type_name(type) : "unknown");
}
if (!show_only)
unlink_or_warn(fullpath);

View File

@ -289,20 +289,20 @@ static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *no
const char *message, void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
struct commit *old, *new;
struct commit *old_commit, *new_commit;
if (timestamp < cb->cmd.expire_total)
return 1;
old = new = NULL;
old_commit = new_commit = NULL;
if (cb->cmd.stalefix &&
(!keep_entry(&old, ooid) || !keep_entry(&new, noid)))
(!keep_entry(&old_commit, ooid) || !keep_entry(&new_commit, noid)))
return 1;
if (timestamp < cb->cmd.expire_unreachable) {
if (cb->unreachable_expire_kind == UE_ALWAYS)
return 1;
if (unreachable(cb, old, ooid) || unreachable(cb, new, noid))
if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
return 1;
}

View File

@ -322,7 +322,7 @@ static void read_branches(void)
struct ref_states {
struct remote *remote;
struct string_list new, stale, tracked, heads, push;
struct string_list new_refs, stale, tracked, heads, push;
int queried;
};
@ -337,12 +337,12 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
die(_("Could not get fetch map for refspec %s"),
states->remote->fetch_refspec[i]);
states->new.strdup_strings = 1;
states->new_refs.strdup_strings = 1;
states->tracked.strdup_strings = 1;
states->stale.strdup_strings = 1;
for (ref = fetch_map; ref; ref = ref->next) {
if (!ref->peer_ref || !ref_exists(ref->peer_ref->name))
string_list_append(&states->new, abbrev_branch(ref->name));
string_list_append(&states->new_refs, abbrev_branch(ref->name));
else
string_list_append(&states->tracked, abbrev_branch(ref->name));
}
@ -356,7 +356,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
free_refs(stale_refs);
free_refs(fetch_map);
string_list_sort(&states->new);
string_list_sort(&states->new_refs);
string_list_sort(&states->tracked);
string_list_sort(&states->stale);
@ -546,8 +546,8 @@ static int add_branch_for_removal(const char *refname,
}
struct rename_info {
const char *old;
const char *new;
const char *old_name;
const char *new_name;
struct string_list *remote_branches;
};
@ -560,7 +560,7 @@ static int read_remote_branches(const char *refname,
int flag;
const char *symref;
strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name);
if (starts_with(refname, buf.buf)) {
item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
@ -615,36 +615,36 @@ static int mv(int argc, const char **argv)
if (argc != 3)
usage_with_options(builtin_remote_rename_usage, options);
rename.old = argv[1];
rename.new = argv[2];
rename.old_name = argv[1];
rename.new_name = argv[2];
rename.remote_branches = &remote_branches;
oldremote = remote_get(rename.old);
oldremote = remote_get(rename.old_name);
if (!remote_is_configured(oldremote, 1))
die(_("No such remote: %s"), rename.old);
die(_("No such remote: %s"), rename.old_name);
if (!strcmp(rename.old, rename.new) && oldremote->origin != REMOTE_CONFIG)
if (!strcmp(rename.old_name, rename.new_name) && oldremote->origin != REMOTE_CONFIG)
return migrate_file(oldremote);
newremote = remote_get(rename.new);
newremote = remote_get(rename.new_name);
if (remote_is_configured(newremote, 1))
die(_("remote %s already exists."), rename.new);
die(_("remote %s already exists."), rename.new_name);
strbuf_addf(&buf, "refs/heads/test:refs/remotes/%s/test", rename.new);
strbuf_addf(&buf, "refs/heads/test:refs/remotes/%s/test", rename.new_name);
if (!valid_fetch_refspec(buf.buf))
die(_("'%s' is not a valid remote name"), rename.new);
die(_("'%s' is not a valid remote name"), rename.new_name);
strbuf_reset(&buf);
strbuf_addf(&buf, "remote.%s", rename.old);
strbuf_addf(&buf2, "remote.%s", rename.new);
strbuf_addf(&buf, "remote.%s", rename.old_name);
strbuf_addf(&buf2, "remote.%s", rename.new_name);
if (git_config_rename_section(buf.buf, buf2.buf) < 1)
return error(_("Could not rename config section '%s' to '%s'"),
buf.buf, buf2.buf);
strbuf_reset(&buf);
strbuf_addf(&buf, "remote.%s.fetch", rename.new);
strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
git_config_set_multivar(buf.buf, NULL, NULL, 1);
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
char *ptr;
@ -655,8 +655,8 @@ static int mv(int argc, const char **argv)
refspec_updated = 1;
strbuf_splice(&buf2,
ptr-buf2.buf + strlen(":refs/remotes/"),
strlen(rename.old), rename.new,
strlen(rename.new));
strlen(rename.old_name), rename.new_name,
strlen(rename.new_name));
} else
warning(_("Not updating non-default fetch refspec\n"
"\t%s\n"
@ -670,10 +670,10 @@ static int mv(int argc, const char **argv)
for (i = 0; i < branch_list.nr; i++) {
struct string_list_item *item = branch_list.items + i;
struct branch_info *info = item->util;
if (info->remote_name && !strcmp(info->remote_name, rename.old)) {
if (info->remote_name && !strcmp(info->remote_name, rename.old_name)) {
strbuf_reset(&buf);
strbuf_addf(&buf, "branch.%s.remote", item->string);
git_config_set(buf.buf, rename.new);
git_config_set(buf.buf, rename.new_name);
}
}
@ -703,8 +703,8 @@ static int mv(int argc, const char **argv)
continue;
strbuf_reset(&buf);
strbuf_addstr(&buf, item->string);
strbuf_splice(&buf, strlen("refs/remotes/"), strlen(rename.old),
rename.new, strlen(rename.new));
strbuf_splice(&buf, strlen("refs/remotes/"), strlen(rename.old_name),
rename.new_name, strlen(rename.new_name));
strbuf_reset(&buf2);
strbuf_addf(&buf2, "remote: renamed %s to %s",
item->string, buf.buf);
@ -718,12 +718,12 @@ static int mv(int argc, const char **argv)
continue;
strbuf_reset(&buf);
strbuf_addstr(&buf, item->string);
strbuf_splice(&buf, strlen("refs/remotes/"), strlen(rename.old),
rename.new, strlen(rename.new));
strbuf_splice(&buf, strlen("refs/remotes/"), strlen(rename.old_name),
rename.new_name, strlen(rename.new_name));
strbuf_reset(&buf2);
strbuf_addstr(&buf2, item->util);
strbuf_splice(&buf2, strlen("refs/remotes/"), strlen(rename.old),
rename.new, strlen(rename.new));
strbuf_splice(&buf2, strlen("refs/remotes/"), strlen(rename.old_name),
rename.new_name, strlen(rename.new_name));
strbuf_reset(&buf3);
strbuf_addf(&buf3, "remote: renamed %s to %s",
item->string, buf.buf);
@ -822,7 +822,7 @@ static void clear_push_info(void *util, const char *string)
static void free_remote_ref_states(struct ref_states *states)
{
string_list_clear(&states->new, 0);
string_list_clear(&states->new_refs, 0);
string_list_clear(&states->stale, 1);
string_list_clear(&states->tracked, 0);
string_list_clear(&states->heads, 0);
@ -907,7 +907,7 @@ static int show_remote_info_item(struct string_list_item *item, void *cb_data)
if (states->queried) {
const char *fmt = "%s";
const char *arg = "";
if (string_list_has_string(&states->new, name)) {
if (string_list_has_string(&states->new_refs, name)) {
fmt = _(" new (next fetch will store in remotes/%s)");
arg = states->remote->name;
} else if (string_list_has_string(&states->tracked, name))
@ -1176,7 +1176,7 @@ static int show(int argc, const char **argv)
/* remote branch info */
info.width = 0;
for_each_string_list(&states.new, add_remote_to_show_info, &info);
for_each_string_list(&states.new_refs, add_remote_to_show_info, &info);
for_each_string_list(&states.tracked, add_remote_to_show_info, &info);
for_each_string_list(&states.stale, add_remote_to_show_info, &info);
if (info.list->nr)

View File

@ -56,8 +56,8 @@ static int show_reference(const char *refname, const struct object_id *oid,
obj_type = sha1_object_info(object.hash, NULL);
repl_type = sha1_object_info(oid->hash, NULL);
printf("%s (%s) -> %s (%s)\n", refname, typename(obj_type),
oid_to_hex(oid), typename(repl_type));
printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
oid_to_hex(oid), type_name(repl_type));
}
}
@ -168,8 +168,8 @@ static int replace_object_oid(const char *object_ref,
die("Objects must be of the same type.\n"
"'%s' points to a replaced object of type '%s'\n"
"while '%s' points to a replacement object of type '%s'.",
object_ref, typename(obj_type),
replace_ref, typename(repl_type));
object_ref, type_name(obj_type),
replace_ref, type_name(repl_type));
check_ref_valid(object, &prev, &ref, force);
@ -215,7 +215,7 @@ static void export_object(const struct object_id *oid, enum object_type type,
argv_array_push(&cmd.args, "--no-replace-objects");
argv_array_push(&cmd.args, "cat-file");
if (raw)
argv_array_push(&cmd.args, typename(type));
argv_array_push(&cmd.args, type_name(type));
else
argv_array_push(&cmd.args, "-p");
argv_array_push(&cmd.args, oid_to_hex(oid));
@ -284,30 +284,30 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
{
char *tmpfile = git_pathdup("REPLACE_EDITOBJ");
enum object_type type;
struct object_id old, new, prev;
struct object_id old_oid, new_oid, prev;
struct strbuf ref = STRBUF_INIT;
if (get_oid(object_ref, &old) < 0)
if (get_oid(object_ref, &old_oid) < 0)
die("Not a valid object name: '%s'", object_ref);
type = sha1_object_info(old.hash, NULL);
type = sha1_object_info(old_oid.hash, NULL);
if (type < 0)
die("unable to get object type for %s", oid_to_hex(&old));
die("unable to get object type for %s", oid_to_hex(&old_oid));
check_ref_valid(&old, &prev, &ref, force);
check_ref_valid(&old_oid, &prev, &ref, force);
strbuf_release(&ref);
export_object(&old, type, raw, tmpfile);
export_object(&old_oid, type, raw, tmpfile);
if (launch_editor(tmpfile, NULL, NULL) < 0)
die("editing object file failed");
import_object(&new, type, raw, tmpfile);
import_object(&new_oid, type, raw, tmpfile);
free(tmpfile);
if (!oidcmp(&old, &new))
return error("new object is the same as the old one: '%s'", oid_to_hex(&old));
if (!oidcmp(&old_oid, &new_oid))
return error("new object is the same as the old one: '%s'", oid_to_hex(&old_oid));
return replace_object_oid(object_ref, &old, "replacement", &new, force);
return replace_object_oid(object_ref, &old_oid, "replacement", &new_oid, force);
}
static void replace_parents(struct strbuf *buf, int argc, const char **argv)
@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,
struct tag *tag;
int i;
hash_object_file(extra->value, extra->len, typename(OBJ_TAG), &tag_oid);
hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid);
tag = lookup_tag(&tag_oid);
if (!tag)
die(_("bad mergetag in commit '%s'"), ref);
@ -386,16 +386,16 @@ static void check_mergetags(struct commit *commit, int argc, const char **argv)
static int create_graft(int argc, const char **argv, int force)
{
struct object_id old, new;
struct object_id old_oid, new_oid;
const char *old_ref = argv[0];
struct commit *commit;
struct strbuf buf = STRBUF_INIT;
const char *buffer;
unsigned long size;
if (get_oid(old_ref, &old) < 0)
if (get_oid(old_ref, &old_oid) < 0)
die(_("Not a valid object name: '%s'"), old_ref);
commit = lookup_commit_or_die(&old, old_ref);
commit = lookup_commit_or_die(&old_oid, old_ref);
buffer = get_commit_buffer(commit, &size);
strbuf_add(&buf, buffer, size);
@ -410,15 +410,15 @@ static int create_graft(int argc, const char **argv, int force)
check_mergetags(commit, argc, argv);
if (write_object_file(buf.buf, buf.len, commit_type, &new))
if (write_object_file(buf.buf, buf.len, commit_type, &new_oid))
die(_("could not write replacement commit for: '%s'"), old_ref);
strbuf_release(&buf);
if (!oidcmp(&old, &new))
return error("new commit is the same as the old one: '%s'", oid_to_hex(&old));
if (!oidcmp(&old_oid, &new_oid))
return error("new commit is the same as the old one: '%s'", oid_to_hex(&old_oid));
return replace_object_oid(old_ref, &old, "replacement", &new, force);
return replace_object_oid(old_ref, &old_oid, "replacement", &new_oid, force);
}
int cmd_replace(int argc, const char **argv, const char *prefix)

View File

@ -243,28 +243,28 @@ static int show_file(const char *arg, int output_prefix)
static int try_difference(const char *arg)
{
char *dotdot;
struct object_id oid;
struct object_id end;
const char *next;
const char *this;
struct object_id start_oid;
struct object_id end_oid;
const char *end;
const char *start;
int symmetric;
static const char head_by_default[] = "HEAD";
if (!(dotdot = strstr(arg, "..")))
return 0;
next = dotdot + 2;
this = arg;
symmetric = (*next == '.');
end = dotdot + 2;
start = arg;
symmetric = (*end == '.');
*dotdot = 0;
next += symmetric;
end += symmetric;
if (!*next)
next = head_by_default;
if (!*end)
end = head_by_default;
if (dotdot == arg)
this = head_by_default;
start = head_by_default;
if (this == head_by_default && next == head_by_default &&
if (start == head_by_default && end == head_by_default &&
!symmetric) {
/*
* Just ".."? That is not a range but the
@ -274,14 +274,14 @@ static int try_difference(const char *arg)
return 0;
}
if (!get_oid_committish(this, &oid) && !get_oid_committish(next, &end)) {
show_rev(NORMAL, &end, next);
show_rev(symmetric ? NORMAL : REVERSED, &oid, this);
if (!get_oid_committish(start, &start_oid) && !get_oid_committish(end, &end_oid)) {
show_rev(NORMAL, &end_oid, end);
show_rev(symmetric ? NORMAL : REVERSED, &start_oid, start);
if (symmetric) {
struct commit_list *exclude;
struct commit *a, *b;
a = lookup_commit_reference(&oid);
b = lookup_commit_reference(&end);
a = lookup_commit_reference(&start_oid);
b = lookup_commit_reference(&end_oid);
exclude = get_merge_bases(a, b);
while (exclude) {
struct commit *commit = pop_commit(&exclude);

View File

@ -221,7 +221,7 @@ static void create_tag(const struct object_id *object, const char *tag,
"tag %s\n"
"tagger %s\n\n",
oid_to_hex(object),
typename(type),
type_name(type),
tag,
git_committer_info(IDENT_STRICT));

View File

@ -173,7 +173,7 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
struct object_id oid;
if (write_object_file(obj_buf->buffer, obj_buf->size,
typename(obj->type), &oid) < 0)
type_name(obj->type), &oid) < 0)
die("failed to write object %s", oid_to_hex(&obj->oid));
obj->flags |= FLAG_WRITTEN;
}
@ -238,7 +238,7 @@ static void write_object(unsigned nr, enum object_type type,
void *buf, unsigned long size)
{
if (!strict) {
if (write_object_file(buf, size, typename(type),
if (write_object_file(buf, size, type_name(type),
&obj_list[nr].oid) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
@ -246,7 +246,7 @@ static void write_object(unsigned nr, enum object_type type,
obj_list[nr].obj = NULL;
} else if (type == OBJ_BLOB) {
struct blob *blob;
if (write_object_file(buf, size, typename(type),
if (write_object_file(buf, size, type_name(type),
&obj_list[nr].oid) < 0)
die("failed to write object");
added_object(nr, type, buf, size);
@ -261,12 +261,12 @@ static void write_object(unsigned nr, enum object_type type,
} else {
struct object *obj;
int eaten;
hash_object_file(buf, size, typename(type), &obj_list[nr].oid);
hash_object_file(buf, size, type_name(type), &obj_list[nr].oid);
added_object(nr, type, buf, size);
obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
&eaten);
if (!obj)
die("invalid %s", typename(type));
die("invalid %s", type_name(type));
add_object_buffer(obj, buf, size);
obj->flags |= FLAG_OPEN;
obj_list[nr].obj = obj;

View File

@ -49,7 +49,7 @@ static int verify_commit(const char *name, unsigned flags)
return error("%s: unable to read file.", name);
if (type != OBJ_COMMIT)
return error("%s: cannot verify a non-commit object of type %s.",
name, typename(type));
name, type_name(type));
ret = run_gpg_verify(&oid, buf, size, flags);

View File

@ -203,7 +203,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
return error("cannot find the current offset");
header_len = xsnprintf((char *)obuf, sizeof(obuf), "%s %" PRIuMAX,
typename(type), (uintmax_t)size) + 1;
type_name(type), (uintmax_t)size) + 1;
the_hash_algo->init_fn(&ctx);
the_hash_algo->update_fn(&ctx, obuf, header_len);

View File

@ -1661,7 +1661,7 @@ struct pack_entry {
* usual "XXXXXX" trailer, and the resulting filename is written into the
* "template" buffer. Returns the open descriptor.
*/
extern int odb_mkstemp(struct strbuf *template, const char *pattern);
extern int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
/*
* Create a pack .keep file named "name" (which should generally be the output
@ -1732,7 +1732,7 @@ struct object_info {
unsigned long *sizep;
off_t *disk_sizep;
unsigned char *delta_base_sha1;
struct strbuf *typename;
struct strbuf *type_name;
void **contentp;
/* Response */

View File

@ -162,7 +162,7 @@ enum coalesce_direction { MATCH, BASE, NEW };
/* Coalesce new lines into base by finding LCS */
static struct lline *coalesce_lines(struct lline *base, int *lenbase,
struct lline *new, int lennew,
struct lline *newline, int lennew,
unsigned long parent, long flags)
{
int **lcs;
@ -170,12 +170,12 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
struct lline *baseend, *newend = NULL;
int i, j, origbaselen = *lenbase;
if (new == NULL)
if (newline == NULL)
return base;
if (base == NULL) {
*lenbase = lennew;
return new;
return newline;
}
/*
@ -200,7 +200,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
directions[0][j] = NEW;
for (i = 1, baseend = base; i < origbaselen + 1; i++) {
for (j = 1, newend = new; j < lennew + 1; j++) {
for (j = 1, newend = newline; j < lennew + 1; j++) {
if (match_string_spaces(baseend->line, baseend->len,
newend->line, newend->len, flags)) {
lcs[i][j] = lcs[i - 1][j - 1] + 1;
@ -241,7 +241,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
if (lline->prev)
lline->prev->next = lline->next;
else
new = lline->next;
newline = lline->next;
if (lline->next)
lline->next->prev = lline->prev;
@ -270,7 +270,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
}
}
newend = new;
newend = newline;
while (newend) {
struct lline *lline = newend;
newend = newend->next;

View File

@ -272,7 +272,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
oid_to_hex(&commit->object.oid));
if (type != OBJ_COMMIT)
die("expected commit for %s, got %s",
oid_to_hex(&commit->object.oid), typename(type));
oid_to_hex(&commit->object.oid), type_name(type));
if (sizep)
*sizep = size;
}
@ -859,19 +859,19 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
commit_list_insert(in->item, &ret);
for (i = in->next; i; i = i->next) {
struct commit_list *new = NULL, *end = NULL;
struct commit_list *new_commits = NULL, *end = NULL;
for (j = ret; j; j = j->next) {
struct commit_list *bases;
bases = get_merge_bases(i->item, j->item);
if (!new)
new = bases;
if (!new_commits)
new_commits = bases;
else
end->next = bases;
for (k = bases; k; k = k->next)
end = k;
}
ret = new;
ret = new_commits;
}
return ret;
}
@ -1614,11 +1614,11 @@ struct commit *get_merge_parent(const char *name)
struct commit_list **commit_list_append(struct commit *commit,
struct commit_list **next)
{
struct commit_list *new = xmalloc(sizeof(struct commit_list));
new->item = commit;
*next = new;
new->next = NULL;
return &new->next;
struct commit_list *new_commit = xmalloc(sizeof(struct commit_list));
new_commit->item = commit;
*next = new_commit;
new_commit->next = NULL;
return &new_commit->next;
}
const char *find_commit_header(const char *msg, const char *key, size_t *out_len)

View File

@ -15,7 +15,7 @@ static char *get_stdin(void)
static void show_new(enum object_type type, unsigned char *sha1_new)
{
fprintf(stderr, " %s: %s\n", typename(type),
fprintf(stderr, " %s: %s\n", type_name(type),
find_unique_abbrev(sha1_new, DEFAULT_ABBREV));
}

View File

@ -304,7 +304,7 @@ static int get_stat_data(const struct cache_entry *ce,
}
static void show_new_file(struct rev_info *revs,
const struct cache_entry *new,
const struct cache_entry *new_file,
int cached, int match_missing)
{
const struct object_id *oid;
@ -315,16 +315,16 @@ static void show_new_file(struct rev_info *revs,
* New file in the index: it might actually be different in
* the working tree.
*/
if (get_stat_data(new, &oid, &mode, cached, match_missing,
if (get_stat_data(new_file, &oid, &mode, cached, match_missing,
&dirty_submodule, &revs->diffopt) < 0)
return;
diff_index_show_file(revs, "+", new, oid, !is_null_oid(oid), mode, dirty_submodule);
diff_index_show_file(revs, "+", new_file, oid, !is_null_oid(oid), mode, dirty_submodule);
}
static int show_modified(struct rev_info *revs,
const struct cache_entry *old,
const struct cache_entry *new,
const struct cache_entry *old_entry,
const struct cache_entry *new_entry,
int report_missing,
int cached, int match_missing)
{
@ -332,47 +332,47 @@ static int show_modified(struct rev_info *revs,
const struct object_id *oid;
unsigned dirty_submodule = 0;
if (get_stat_data(new, &oid, &mode, cached, match_missing,
if (get_stat_data(new_entry, &oid, &mode, cached, match_missing,
&dirty_submodule, &revs->diffopt) < 0) {
if (report_missing)
diff_index_show_file(revs, "-", old,
&old->oid, 1, old->ce_mode,
diff_index_show_file(revs, "-", old_entry,
&old_entry->oid, 1, old_entry->ce_mode,
0);
return -1;
}
if (revs->combine_merges && !cached &&
(oidcmp(oid, &old->oid) || oidcmp(&old->oid, &new->oid))) {
(oidcmp(oid, &old_entry->oid) || oidcmp(&old_entry->oid, &new_entry->oid))) {
struct combine_diff_path *p;
int pathlen = ce_namelen(new);
int pathlen = ce_namelen(new_entry);
p = xmalloc(combine_diff_path_size(2, pathlen));
p->path = (char *) &p->parent[2];
p->next = NULL;
memcpy(p->path, new->name, pathlen);
memcpy(p->path, new_entry->name, pathlen);
p->path[pathlen] = 0;
p->mode = mode;
oidclr(&p->oid);
memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));
p->parent[0].status = DIFF_STATUS_MODIFIED;
p->parent[0].mode = new->ce_mode;
oidcpy(&p->parent[0].oid, &new->oid);
p->parent[0].mode = new_entry->ce_mode;
oidcpy(&p->parent[0].oid, &new_entry->oid);
p->parent[1].status = DIFF_STATUS_MODIFIED;
p->parent[1].mode = old->ce_mode;
oidcpy(&p->parent[1].oid, &old->oid);
p->parent[1].mode = old_entry->ce_mode;
oidcpy(&p->parent[1].oid, &old_entry->oid);
show_combined_diff(p, 2, revs->dense_combined_merges, revs);
free(p);
return 0;
}
oldmode = old->ce_mode;
if (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&
oldmode = old_entry->ce_mode;
if (mode == oldmode && !oidcmp(oid, &old_entry->oid) && !dirty_submodule &&
!revs->diffopt.flags.find_copies_harder)
return 0;
diff_change(&revs->diffopt, oldmode, mode,
&old->oid, oid, 1, !is_null_oid(oid),
old->name, 0, dirty_submodule);
&old_entry->oid, oid, 1, !is_null_oid(oid),
old_entry->name, 0, dirty_submodule);
return 0;
}

70
diff.c
View File

@ -1504,7 +1504,7 @@ struct diff_words_style_elem {
struct diff_words_style {
enum diff_words_type type;
struct diff_words_style_elem new, old, ctx;
struct diff_words_style_elem new_word, old_word, ctx;
const char *newline;
};
@ -1655,12 +1655,12 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
}
if (minus_begin != minus_end) {
fn_out_diff_words_write_helper(diff_words->opt,
&style->old, style->newline,
&style->old_word, style->newline,
minus_end - minus_begin, minus_begin);
}
if (plus_begin != plus_end) {
fn_out_diff_words_write_helper(diff_words->opt,
&style->new, style->newline,
&style->new_word, style->newline,
plus_end - plus_begin, plus_begin);
}
@ -1758,7 +1758,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
emit_diff_symbol(diff_words->opt, DIFF_SYMBOL_WORD_DIFF,
line_prefix, strlen(line_prefix), 0);
fn_out_diff_words_write_helper(diff_words->opt,
&style->old, style->newline,
&style->old_word, style->newline,
diff_words->minus.text.size,
diff_words->minus.text.ptr);
diff_words->minus.text.size = 0;
@ -1883,8 +1883,8 @@ static void init_diff_words_data(struct emit_callback *ecbdata,
}
if (want_color(o->use_color)) {
struct diff_words_style *st = ecbdata->diff_words->style;
st->old.color = diff_get_color_opt(o, DIFF_FILE_OLD);
st->new.color = diff_get_color_opt(o, DIFF_FILE_NEW);
st->old_word.color = diff_get_color_opt(o, DIFF_FILE_OLD);
st->new_word.color = diff_get_color_opt(o, DIFF_FILE_NEW);
st->ctx.color = diff_get_color_opt(o, DIFF_CONTEXT);
}
}
@ -2047,8 +2047,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
static char *pprint_rename(const char *a, const char *b)
{
const char *old = a;
const char *new = b;
const char *old_name = a;
const char *new_name = b;
struct strbuf name = STRBUF_INIT;
int pfx_length, sfx_length;
int pfx_adjust_for_slash;
@ -2067,16 +2067,16 @@ static char *pprint_rename(const char *a, const char *b)
/* Find common prefix */
pfx_length = 0;
while (*old && *new && *old == *new) {
if (*old == '/')
pfx_length = old - a + 1;
old++;
new++;
while (*old_name && *new_name && *old_name == *new_name) {
if (*old_name == '/')
pfx_length = old_name - a + 1;
old_name++;
new_name++;
}
/* Find common suffix */
old = a + len_a;
new = b + len_b;
old_name = a + len_a;
new_name = b + len_b;
sfx_length = 0;
/*
* If there is a common prefix, it must end in a slash. In
@ -2087,13 +2087,13 @@ static char *pprint_rename(const char *a, const char *b)
* underrun the input strings.
*/
pfx_adjust_for_slash = (pfx_length ? 1 : 0);
while (a + pfx_length - pfx_adjust_for_slash <= old &&
b + pfx_length - pfx_adjust_for_slash <= new &&
*old == *new) {
if (*old == '/')
sfx_length = len_a - (old - a);
old--;
new--;
while (a + pfx_length - pfx_adjust_for_slash <= old_name &&
b + pfx_length - pfx_adjust_for_slash <= new_name &&
*old_name == *new_name) {
if (*old_name == '/')
sfx_length = len_a - (old_name - a);
old_name--;
new_name--;
}
/*
@ -2594,14 +2594,14 @@ struct dirstat_dir {
static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
unsigned long changed, const char *base, int baselen)
{
unsigned long this_dir = 0;
unsigned long sum_changes = 0;
unsigned int sources = 0;
const char *line_prefix = diff_line_prefix(opt);
while (dir->nr) {
struct dirstat_file *f = dir->files;
int namelen = strlen(f->name);
unsigned long this;
unsigned long changes;
char *slash;
if (namelen < baselen)
@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
slash = strchr(f->name + baselen, '/');
if (slash) {
int newbaselen = slash + 1 - f->name;
this = gather_dirstat(opt, dir, changed, f->name, newbaselen);
changes = gather_dirstat(opt, dir, changed, f->name, newbaselen);
sources++;
} else {
this = f->changed;
changes = f->changed;
dir->files++;
dir->nr--;
sources += 2;
}
this_dir += this;
sum_changes += changes;
}
/*
@ -2629,8 +2629,8 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
* under this directory (sources == 1).
*/
if (baselen && sources != 1) {
if (this_dir) {
int permille = this_dir * 1000 / changed;
if (sum_changes) {
int permille = sum_changes * 1000 / changed;
if (permille >= dir->permille) {
fprintf(opt->file, "%s%4d.%01d%% %.*s\n", line_prefix,
permille / 10, permille % 10, baselen, base);
@ -2639,7 +2639,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
}
}
}
return this_dir;
return sum_changes;
}
static int dirstat_compare(const void *_a, const void *_b)
@ -3660,15 +3660,15 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
int mode)
{
struct strbuf buf = STRBUF_INIT;
struct strbuf template = STRBUF_INIT;
struct strbuf tempfile = STRBUF_INIT;
char *path_dup = xstrdup(path);
const char *base = basename(path_dup);
/* Generate "XXXXXX_basename.ext" */
strbuf_addstr(&template, "XXXXXX_");
strbuf_addstr(&template, base);
strbuf_addstr(&tempfile, "XXXXXX_");
strbuf_addstr(&tempfile, base);
temp->tempfile = mks_tempfile_ts(template.buf, strlen(base) + 1);
temp->tempfile = mks_tempfile_ts(tempfile.buf, strlen(base) + 1);
if (!temp->tempfile)
die_errno("unable to create temp-file");
if (convert_to_working_tree(path,
@ -3683,7 +3683,7 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
oid_to_hex_r(temp->hex, oid);
xsnprintf(temp->mode, sizeof(temp->mode), "%06o", mode);
strbuf_release(&buf);
strbuf_release(&template);
strbuf_release(&tempfile);
free(path_dup);
}

View File

@ -48,16 +48,16 @@ struct spanhash_top {
static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
{
struct spanhash_top *new;
struct spanhash_top *new_spanhash;
int i;
int osz = 1 << orig->alloc_log2;
int sz = osz << 1;
new = xmalloc(st_add(sizeof(*orig),
new_spanhash = xmalloc(st_add(sizeof(*orig),
st_mult(sizeof(struct spanhash), sz)));
new->alloc_log2 = orig->alloc_log2 + 1;
new->free = INITIAL_FREE(new->alloc_log2);
memset(new->data, 0, sizeof(struct spanhash) * sz);
new_spanhash->alloc_log2 = orig->alloc_log2 + 1;
new_spanhash->free = INITIAL_FREE(new_spanhash->alloc_log2);
memset(new_spanhash->data, 0, sizeof(struct spanhash) * sz);
for (i = 0; i < osz; i++) {
struct spanhash *o = &(orig->data[i]);
int bucket;
@ -65,11 +65,11 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
continue;
bucket = o->hashval & (sz - 1);
while (1) {
struct spanhash *h = &(new->data[bucket++]);
struct spanhash *h = &(new_spanhash->data[bucket++]);
if (!h->cnt) {
h->hashval = o->hashval;
h->cnt = o->cnt;
new->free--;
new_spanhash->free--;
break;
}
if (sz <= bucket)
@ -77,7 +77,7 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
}
}
free(orig);
return new;
return new_spanhash;
}
static struct spanhash_top *add_spanhash(struct spanhash_top *top,

40
entry.c
View File

@ -85,12 +85,12 @@ static int create_file(const char *path, unsigned int mode)
static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)
{
enum object_type type;
void *new = read_sha1_file(ce->oid.hash, &type, size);
void *blob_data = read_sha1_file(ce->oid.hash, &type, size);
if (new) {
if (blob_data) {
if (type == OBJ_BLOB)
return new;
free(new);
return blob_data;
free(blob_data);
}
return NULL;
}
@ -256,7 +256,7 @@ static int write_entry(struct cache_entry *ce,
unsigned int ce_mode_s_ifmt = ce->ce_mode & S_IFMT;
struct delayed_checkout *dco = state->delayed_checkout;
int fd, ret, fstat_done = 0;
char *new;
char *new_blob;
struct strbuf buf = STRBUF_INIT;
unsigned long size;
ssize_t wrote;
@ -276,8 +276,8 @@ static int write_entry(struct cache_entry *ce,
switch (ce_mode_s_ifmt) {
case S_IFLNK:
new = read_blob_entry(ce, &size);
if (!new)
new_blob = read_blob_entry(ce, &size);
if (!new_blob)
return error("unable to read sha1 file of %s (%s)",
path, oid_to_hex(&ce->oid));
@ -288,8 +288,8 @@ static int write_entry(struct cache_entry *ce,
if (!has_symlinks || to_tempfile)
goto write_file_entry;
ret = symlink(new, path);
free(new);
ret = symlink(new_blob, path);
free(new_blob);
if (ret)
return error_errno("unable to create symlink %s", path);
break;
@ -300,11 +300,11 @@ static int write_entry(struct cache_entry *ce,
* bother reading it at all.
*/
if (dco && dco->state == CE_RETRY) {
new = NULL;
new_blob = NULL;
size = 0;
} else {
new = read_blob_entry(ce, &size);
if (!new)
new_blob = read_blob_entry(ce, &size);
if (!new_blob)
return error("unable to read sha1 file of %s (%s)",
path, oid_to_hex(&ce->oid));
}
@ -313,18 +313,18 @@ static int write_entry(struct cache_entry *ce,
* Convert from git internal format to working tree format
*/
if (dco && dco->state != CE_NO_DELAY) {
ret = async_convert_to_working_tree(ce->name, new,
ret = async_convert_to_working_tree(ce->name, new_blob,
size, &buf, dco);
if (ret && string_list_has_string(&dco->paths, ce->name)) {
free(new);
free(new_blob);
goto delayed;
}
} else
ret = convert_to_working_tree(ce->name, new, size, &buf);
ret = convert_to_working_tree(ce->name, new_blob, size, &buf);
if (ret) {
free(new);
new = strbuf_detach(&buf, &newsize);
free(new_blob);
new_blob = strbuf_detach(&buf, &newsize);
size = newsize;
}
/*
@ -336,15 +336,15 @@ static int write_entry(struct cache_entry *ce,
write_file_entry:
fd = open_output_fd(path, ce, to_tempfile);
if (fd < 0) {
free(new);
free(new_blob);
return error_errno("unable to create file %s", path);
}
wrote = write_in_full(fd, new, size);
wrote = write_in_full(fd, new_blob, size);
if (!to_tempfile)
fstat_done = fstat_output(fd, state, &st);
close(fd);
free(new);
free(new_blob);
if (wrote < 0)
return error("unable to write file %s", path);
break;

View File

@ -100,7 +100,7 @@ int ignore_untracked_cache_config;
/* This is set by setup_git_dir_gently() and/or git_default_config() */
char *git_work_tree_cfg;
static char *namespace;
static char *git_namespace;
static const char *super_prefix;
@ -158,8 +158,8 @@ void setup_git_env(void)
free(git_replace_ref_base);
git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
: "refs/replace/");
free(namespace);
namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
free(git_namespace);
git_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
if (shallow_file)
set_alternate_shallow_file(shallow_file, 0);
@ -193,9 +193,9 @@ const char *get_git_common_dir(void)
const char *get_git_namespace(void)
{
if (!namespace)
if (!git_namespace)
BUG("git environment hasn't been setup");
return namespace;
return git_namespace;
}
const char *strip_namespace(const char *namespaced_ref)
@ -249,7 +249,7 @@ char *get_object_directory(void)
return the_repository->objectdir;
}
int odb_mkstemp(struct strbuf *template, const char *pattern)
int odb_mkstemp(struct strbuf *temp_filename, const char *pattern)
{
int fd;
/*
@ -257,16 +257,16 @@ int odb_mkstemp(struct strbuf *template, const char *pattern)
* restrictive except to remove write permission.
*/
int mode = 0444;
git_path_buf(template, "objects/%s", pattern);
fd = git_mkstemp_mode(template->buf, mode);
git_path_buf(temp_filename, "objects/%s", pattern);
fd = git_mkstemp_mode(temp_filename->buf, mode);
if (0 <= fd)
return fd;
/* slow path */
/* some mkstemp implementations erase template on failure */
git_path_buf(template, "objects/%s", pattern);
safe_create_leading_directories(template->buf);
return xmkstemp_mode(template->buf, mode);
/* some mkstemp implementations erase temp_filename on failure */
git_path_buf(temp_filename, "objects/%s", pattern);
safe_create_leading_directories(temp_filename->buf);
return xmkstemp_mode(temp_filename->buf, mode);
}
int odb_pack_keep(const char *name)

View File

@ -1096,7 +1096,7 @@ static int store_object(
git_zstream s;
hdrlen = xsnprintf((char *)hdr, sizeof(hdr), "%s %lu",
typename(type), (unsigned long)dat->len) + 1;
type_name(type), (unsigned long)dat->len) + 1;
the_hash_algo->init_fn(&c);
the_hash_algo->update_fn(&c, hdr, hdrlen);
the_hash_algo->update_fn(&c, dat->buf, dat->len);
@ -2423,7 +2423,7 @@ static void file_change_m(const char *p, struct branch *b)
else if (oe) {
if (oe->type != OBJ_COMMIT)
die("Not a commit (actually a %s): %s",
typename(oe->type), command_buf.buf);
type_name(oe->type), command_buf.buf);
}
/*
* Accept the sha1 without checking; it expected to be in
@ -2450,7 +2450,7 @@ static void file_change_m(const char *p, struct branch *b)
command_buf.buf);
if (type != expected)
die("Not a %s (actually a %s): %s",
typename(expected), typename(type),
type_name(expected), type_name(type),
command_buf.buf);
}
@ -2601,14 +2601,14 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
} else if (oe) {
if (oe->type != OBJ_BLOB)
die("Not a blob (actually a %s): %s",
typename(oe->type), command_buf.buf);
type_name(oe->type), command_buf.buf);
} else if (!is_null_oid(&oid)) {
enum object_type type = sha1_object_info(oid.hash, NULL);
if (type < 0)
die("Blob not found: %s", command_buf.buf);
if (type != OBJ_BLOB)
die("Not a blob (actually a %s): %s",
typename(type), command_buf.buf);
type_name(type), command_buf.buf);
}
construct_path_with_fanout(oid_to_hex(&commit_oid), *old_fanout, path);
@ -2916,7 +2916,7 @@ static void parse_new_tag(const char *arg)
"object %s\n"
"type %s\n"
"tag %s\n",
oid_to_hex(&oid), typename(type), t->name);
oid_to_hex(&oid), type_name(type), t->name);
if (tagger)
strbuf_addf(&new_data,
"tagger %s\n", tagger);
@ -2987,10 +2987,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
die("Can't read object %s", oid_to_hex(oid));
if (type != OBJ_BLOB)
die("Object %s is a %s but a blob was expected.",
oid_to_hex(oid), typename(type));
oid_to_hex(oid), type_name(type));
strbuf_reset(&line);
strbuf_addf(&line, "%s %s %lu\n", oid_to_hex(oid),
typename(type), size);
type_name(type), size);
cat_blob_write(line.buf, line.len);
strbuf_release(&line);
cat_blob_write(buf, size);

2
fsck.c
View File

@ -821,7 +821,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
ret = report(options, &tag->object,
FSCK_MSG_TAG_OBJECT_NOT_TAG,
"expected tag got %s",
typename(type));
type_name(type));
goto done;
}
}

View File

@ -826,8 +826,8 @@ extern ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
extern int xdup(int fd);
extern FILE *xfopen(const char *path, const char *mode);
extern FILE *xfdopen(int fd, const char *mode);
extern int xmkstemp(char *template);
extern int xmkstemp_mode(char *template, int mode);
extern int xmkstemp(char *temp_filename);
extern int xmkstemp_mode(char *temp_filename, int mode);
extern char *xgetcwd(void);
extern FILE *fopen_for_writing(const char *path);
extern FILE *fopen_or_warn(const char *path, const char *mode);

View File

@ -362,7 +362,7 @@ static void start_put(struct transfer_request *request)
git_zstream stream;
unpacked = read_sha1_file(request->obj->oid.hash, &type, &len);
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
/* Set it up */
git_deflate_init(&stream, zlib_compression_level);

10
http.c
View File

@ -1260,14 +1260,14 @@ static struct fill_chain *fill_cfg;
void add_fill_function(void *data, int (*fill)(void *))
{
struct fill_chain *new = xmalloc(sizeof(*new));
struct fill_chain *new_fill = xmalloc(sizeof(*new_fill));
struct fill_chain **linkp = &fill_cfg;
new->data = data;
new->fill = fill;
new->next = NULL;
new_fill->data = data;
new_fill->fill = fill;
new_fill->next = NULL;
while (*linkp)
linkp = &(*linkp)->next;
*linkp = new;
*linkp = new_fill;
}
void fill_active_slots(void)

View File

@ -1189,11 +1189,11 @@ bail:
*/
static void lf_to_crlf(struct strbuf *msg)
{
char *new;
char *new_msg;
size_t i, j;
char lastc;
/* First pass: tally, in j, the size of the new string: */
/* First pass: tally, in j, the size of the new_msg string: */
for (i = j = 0, lastc = '\0'; i < msg->len; i++) {
if (msg->buf[i] == '\n' && lastc != '\r')
j++; /* a CR will need to be added here */
@ -1201,18 +1201,18 @@ static void lf_to_crlf(struct strbuf *msg)
j++;
}
new = xmallocz(j);
new_msg = xmallocz(j);
/*
* Second pass: write the new string. Note that this loop is
* Second pass: write the new_msg string. Note that this loop is
* otherwise identical to the first pass.
*/
for (i = j = 0, lastc = '\0'; i < msg->len; i++) {
if (msg->buf[i] == '\n' && lastc != '\r')
new[j++] = '\r';
lastc = new[j++] = msg->buf[i];
new_msg[j++] = '\r';
lastc = new_msg[j++] = msg->buf[i];
}
strbuf_attach(msg, new, j, j + 1);
strbuf_attach(msg, new_msg, j, j + 1);
}
/*

View File

@ -151,29 +151,29 @@ static void range_set_union(struct range_set *out,
assert(out->nr == 0);
while (i < a->nr || j < b->nr) {
struct range *new;
struct range *new_range;
if (i < a->nr && j < b->nr) {
if (ra[i].start < rb[j].start)
new = &ra[i++];
new_range = &ra[i++];
else if (ra[i].start > rb[j].start)
new = &rb[j++];
new_range = &rb[j++];
else if (ra[i].end < rb[j].end)
new = &ra[i++];
new_range = &ra[i++];
else
new = &rb[j++];
new_range = &rb[j++];
} else if (i < a->nr) /* b exhausted */
new = &ra[i++];
new_range = &ra[i++];
else /* a exhausted */
new = &rb[j++];
if (new->start == new->end)
new_range = &rb[j++];
if (new_range->start == new_range->end)
; /* empty range */
else if (!out->nr || out->ranges[out->nr-1].end < new->start) {
else if (!out->nr || out->ranges[out->nr-1].end < new_range->start) {
range_set_grow(out, 1);
out->ranges[out->nr].start = new->start;
out->ranges[out->nr].end = new->end;
out->ranges[out->nr].start = new_range->start;
out->ranges[out->nr].end = new_range->end;
out->nr++;
} else if (out->ranges[out->nr-1].end < new->end) {
out->ranges[out->nr-1].end = new->end;
} else if (out->ranges[out->nr-1].end < new_range->end) {
out->ranges[out->nr-1].end = new_range->end;
}
}
}
@ -696,18 +696,18 @@ static struct line_log_data *line_log_data_merge(struct line_log_data *a,
static void add_line_range(struct rev_info *revs, struct commit *commit,
struct line_log_data *range)
{
struct line_log_data *old = NULL;
struct line_log_data *new = NULL;
struct line_log_data *old_line = NULL;
struct line_log_data *new_line = NULL;
old = lookup_decoration(&revs->line_log_data, &commit->object);
if (old && range) {
new = line_log_data_merge(old, range);
free_line_log_data(old);
old_line = lookup_decoration(&revs->line_log_data, &commit->object);
if (old_line && range) {
new_line = line_log_data_merge(old_line, range);
free_line_log_data(old_line);
} else if (range)
new = line_log_data_copy(range);
new_line = line_log_data_copy(range);
if (new)
add_decoration(&revs->line_log_data, &commit->object, new);
if (new_line)
add_decoration(&revs->line_log_data, &commit->object, new_line);
}
static void clear_commit_line_range(struct rev_info *revs, struct commit *commit)
@ -1042,12 +1042,12 @@ static int process_diff_filepair(struct rev_info *rev,
static struct diff_filepair *diff_filepair_dup(struct diff_filepair *pair)
{
struct diff_filepair *new = xmalloc(sizeof(struct diff_filepair));
new->one = pair->one;
new->two = pair->two;
new->one->count++;
new->two->count++;
return new;
struct diff_filepair *new_filepair = xmalloc(sizeof(struct diff_filepair));
new_filepair->one = pair->one;
new_filepair->two = pair->two;
new_filepair->one->count++;
new_filepair->two->count++;
return new_filepair;
}
static void free_diffqueues(int n, struct diff_queue_struct *dq)

View File

@ -499,7 +499,7 @@ static void show_one_mergetag(struct commit *commit,
int status, nth;
size_t payload_size, gpg_message_offset;
hash_object_file(extra->value, extra->len, typename(OBJ_TAG), &oid);
hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid);
tag = lookup_tag(&oid);
if (!tag)
return; /* error message already given */

View File

@ -26,7 +26,7 @@ static const char *object_type_strings[] = {
"tag", /* OBJ_TAG = 4 */
};
const char *typename(unsigned int type)
const char *type_name(unsigned int type)
{
if (type >= ARRAY_SIZE(object_type_strings))
return NULL;
@ -166,7 +166,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
if (!quiet)
error("object %s is a %s, not a %s",
oid_to_hex(&obj->oid),
typename(obj->type), typename(type));
type_name(obj->type), type_name(type));
return NULL;
}
}
@ -265,7 +265,7 @@ struct object *parse_object(const struct object_id *oid)
buffer = read_sha1_file(oid->hash, &type, &size);
if (buffer) {
if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {
if (check_sha1_signature(repl, buffer, size, type_name(type)) < 0) {
free(buffer);
error("sha1 mismatch %s", sha1_to_hex(repl));
return NULL;

View File

@ -53,7 +53,7 @@ struct object {
struct object_id oid;
};
extern const char *typename(unsigned int type);
extern const char *type_name(unsigned int type);
extern int type_from_string_gently(const char *str, ssize_t, int gentle);
#define type_from_string(str) type_from_string_gently(str, -1, 0)

View File

@ -141,7 +141,7 @@ static int verify_packfile(struct packed_git *p,
err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
oid_to_hex(entries[i].oid.oid), p->pack_name,
(uintmax_t)entries[i].offset);
else if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type)))
else if (check_sha1_signature(entries[i].oid.hash, data, size, type_name(type)))
err = error("packed %s from %s is corrupt",
oid_to_hex(entries[i].oid.oid), p->pack_name);
else if (fn) {

View File

@ -1361,16 +1361,16 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,
*oi->disk_sizep = revidx[1].offset - obj_offset;
}
if (oi->typep || oi->typename) {
if (oi->typep || oi->type_name) {
enum object_type ptot;
ptot = packed_to_object_type(p, obj_offset, type, &w_curs,
curpos);
if (oi->typep)
*oi->typep = ptot;
if (oi->typename) {
const char *tn = typename(ptot);
if (oi->type_name) {
const char *tn = type_name(ptot);
if (tn)
strbuf_addstr(oi->typename, tn);
strbuf_addstr(oi->type_name, tn);
}
if (ptot < 0) {
type = OBJ_BAD;

View File

@ -94,7 +94,7 @@ static void add_recent_object(const struct object_id *oid,
break;
default:
die("unknown object type for %s: %s",
oid_to_hex(oid), typename(type));
oid_to_hex(oid), type_name(type));
}
if (!obj)

View File

@ -70,20 +70,20 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cache
void rename_index_entry_at(struct index_state *istate, int nr, const char *new_name)
{
struct cache_entry *old = istate->cache[nr], *new;
struct cache_entry *old_entry = istate->cache[nr], *new_entry;
int namelen = strlen(new_name);
new = xmalloc(cache_entry_size(namelen));
copy_cache_entry(new, old);
new->ce_flags &= ~CE_HASHED;
new->ce_namelen = namelen;
new->index = 0;
memcpy(new->name, new_name, namelen + 1);
new_entry = xmalloc(cache_entry_size(namelen));
copy_cache_entry(new_entry, old_entry);
new_entry->ce_flags &= ~CE_HASHED;
new_entry->ce_namelen = namelen;
new_entry->index = 0;
memcpy(new_entry->name, new_name, namelen + 1);
cache_tree_invalidate_path(istate, old->name);
untracked_cache_remove_from_index(istate, old->name);
cache_tree_invalidate_path(istate, old_entry->name);
untracked_cache_remove_from_index(istate, old_entry->name);
remove_index_entry_at(istate, nr);
add_index_entry(istate, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
add_index_entry(istate, new_entry, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
}
void fill_stat_data(struct stat_data *sd, struct stat *st)
@ -615,18 +615,18 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
struct cache_entry *alias)
{
int len;
struct cache_entry *new;
struct cache_entry *new_entry;
if (alias->ce_flags & CE_ADDED)
die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
/* Ok, create the new entry using the name of the existing alias */
len = ce_namelen(alias);
new = xcalloc(1, cache_entry_size(len));
memcpy(new->name, alias->name, len);
copy_cache_entry(new, ce);
new_entry = xcalloc(1, cache_entry_size(len));
memcpy(new_entry->name, alias->name, len);
copy_cache_entry(new_entry, ce);
save_or_free_index_entry(istate, ce);
return new;
return new_entry;
}
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
@ -1379,7 +1379,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new;
struct cache_entry *ce, *new_entry;
int cache_errno = 0;
int changed = 0;
int filtered = 0;
@ -1408,10 +1408,10 @@ int refresh_index(struct index_state *istate, unsigned int flags,
if (filtered)
continue;
new = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);
if (new == ce)
new_entry = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);
if (new_entry == ce)
continue;
if (!new) {
if (!new_entry) {
const char *fmt;
if (really && cache_errno == EINVAL) {
@ -1440,7 +1440,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
continue;
}
replace_index_entry(istate, i, new);
replace_index_entry(istate, i, new_entry);
}
trace_performance_since(start, "refresh index");
return has_errors;

View File

@ -529,12 +529,12 @@ static void end_align_handler(struct ref_formatting_stack **stack)
static void align_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state)
{
struct ref_formatting_stack *new;
struct ref_formatting_stack *new_stack;
push_stack_element(&state->stack);
new = state->stack;
new->at_end = end_align_handler;
new->at_end_data = &atomv->atom->u.align;
new_stack = state->stack;
new_stack->at_end = end_align_handler;
new_stack->at_end_data = &atomv->atom->u.align;
}
static void if_then_else_handler(struct ref_formatting_stack **stack)
@ -574,16 +574,16 @@ static void if_then_else_handler(struct ref_formatting_stack **stack)
static void if_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state)
{
struct ref_formatting_stack *new;
struct ref_formatting_stack *new_stack;
struct if_then_else *if_then_else = xcalloc(sizeof(struct if_then_else), 1);
if_then_else->str = atomv->atom->u.if_then_else.str;
if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status;
push_stack_element(&state->stack);
new = state->stack;
new->at_end = if_then_else_handler;
new->at_end_data = if_then_else;
new_stack = state->stack;
new_stack->at_end = if_then_else_handler;
new_stack->at_end_data = if_then_else;
}
static int is_empty(const char *s)
@ -769,7 +769,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
if (deref)
name++;
if (!strcmp(name, "objecttype"))
v->s = typename(obj->type);
v->s = type_name(obj->type);
else if (!strcmp(name, "objectsize")) {
v->value = sz;
v->s = xstrfmt("%lu", sz);
@ -795,7 +795,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
if (!strcmp(name, "tag"))
v->s = tag->tag;
else if (!strcmp(name, "type") && tag->tagged)
v->s = typename(tag->tagged->type);
v->s = type_name(tag->tagged->type);
else if (!strcmp(name, "object") && tag->tagged)
v->s = xstrdup(oid_to_hex(&tag->tagged->oid));
}

View File

@ -1985,33 +1985,33 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)
int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
{
struct object *o;
struct commit *old, *new;
struct commit *old_commit, *new_commit;
struct commit_list *list, *used;
int found = 0;
/*
* Both new and old must be commit-ish and new is descendant of
* old. Otherwise we require --force.
* Both new_commit and old_commit must be commit-ish and new_commit is descendant of
* old_commit. Otherwise we require --force.
*/
o = deref_tag(parse_object(old_oid), NULL, 0);
if (!o || o->type != OBJ_COMMIT)
return 0;
old = (struct commit *) o;
old_commit = (struct commit *) o;
o = deref_tag(parse_object(new_oid), NULL, 0);
if (!o || o->type != OBJ_COMMIT)
return 0;
new = (struct commit *) o;
new_commit = (struct commit *) o;
if (parse_commit(new) < 0)
if (parse_commit(new_commit) < 0)
return 0;
used = list = NULL;
commit_list_insert(new, &list);
commit_list_insert(new_commit, &list);
while (list) {
new = pop_most_recent_commit(&list, TMP_MARK);
commit_list_insert(new, &used);
if (new == old) {
new_commit = pop_most_recent_commit(&list, TMP_MARK);
commit_list_insert(new_commit, &used);
if (new_commit == old_commit) {
found = 1;
break;
}

View File

@ -2883,7 +2883,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
if (!lookup_commit_reference_gently(&oid, 1)) {
enum object_type type = sha1_object_info(oid.hash, NULL);
return error(_("%s: can't cherry-pick a %s"),
name, typename(type));
name, type_name(type));
}
} else
return error(_("%s: bad revision"), name);

View File

@ -804,7 +804,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map,
return -1;
/* Generate the header */
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(obj_type), size) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(obj_type), size) + 1;
/* Sha1.. */
the_hash_algo->init_fn(&c);
@ -1094,8 +1094,8 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,
}
type = type_from_string_gently(type_buf, type_len, 1);
if (oi->typename)
strbuf_add(oi->typename, type_buf, type_len);
if (oi->type_name)
strbuf_add(oi->type_name, type_buf, type_len);
/*
* Set type to 0 if its an unknown object and
* we're obtaining the type using '--allow-unknown-type'
@ -1165,7 +1165,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
* return value implicitly indicates whether the
* object even exists.
*/
if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) {
if (!oi->typep && !oi->type_name && !oi->sizep && !oi->contentp) {
const char *path;
struct stat st;
if (stat_sha1_file(sha1, &st, &path) < 0)
@ -1249,8 +1249,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
*(oi->disk_sizep) = 0;
if (oi->delta_base_sha1)
hashclr(oi->delta_base_sha1);
if (oi->typename)
strbuf_addstr(oi->typename, typename(co->type));
if (oi->type_name)
strbuf_addstr(oi->type_name, type_name(co->type));
if (oi->contentp)
*oi->contentp = xmemdupz(co->buf, co->size);
oi->whence = OI_CACHED;
@ -1339,7 +1339,7 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
{
struct cached_object *co;
hash_object_file(buf, len, typename(type), oid);
hash_object_file(buf, len, type_name(type), oid);
if (has_sha1_file(oid->hash) || find_cached_object(oid->hash))
return 0;
ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
@ -1714,7 +1714,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
buf = read_object(oid->hash, &type, &len);
if (!buf)
return error("cannot read sha1_file for %s", oid_to_hex(oid));
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1;
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime);
free(buf);
@ -1798,9 +1798,9 @@ static int index_mem(struct object_id *oid, void *buf, size_t size,
}
if (write_object)
ret = write_object_file(buf, size, typename(type), oid);
ret = write_object_file(buf, size, type_name(type), oid);
else
ret = hash_object_file(buf, size, typename(type), oid);
ret = hash_object_file(buf, size, type_name(type), oid);
if (re_allocated)
free(buf);
return ret;
@ -1820,10 +1820,10 @@ static int index_stream_convert_blob(struct object_id *oid, int fd,
get_conv_flags(flags));
if (write_object)
ret = write_object_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB),
ret = write_object_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB),
oid);
else
ret = hash_object_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB),
ret = hash_object_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB),
oid);
strbuf_release(&sbuf);
return ret;
@ -1973,7 +1973,7 @@ void assert_sha1_type(const unsigned char *sha1, enum object_type expect)
die("%s is not a valid object", sha1_to_hex(sha1));
if (type != expect)
die("%s is not a valid '%s' object", sha1_to_hex(sha1),
typename(expect));
type_name(expect));
}
int for_each_file_in_obj_subdir(unsigned int subdir_nr,
@ -2218,7 +2218,7 @@ int read_loose_object(const char *path,
goto out;
}
if (check_sha1_signature(expected_sha1, *contents,
*size, typename(*type))) {
*size, type_name(*type))) {
error("sha1 mismatch for %s (expected %s)", path,
sha1_to_hex(expected_sha1));
free(*contents);

View File

@ -381,7 +381,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
advise(" %s %s%s",
find_unique_abbrev(oid->hash, DEFAULT_ABBREV),
typename(type) ? typename(type) : "unknown type",
type_name(type) ? type_name(type) : "unknown type",
desc.buf);
strbuf_release(&desc);
@ -901,8 +901,8 @@ struct object *peel_to_type(const char *name, int namelen,
if (name)
error("%.*s: expected %s type, but the object "
"dereferences to %s type",
namelen, name, typename(expected_type),
typename(o->type));
namelen, name, type_name(expected_type),
type_name(o->type));
return NULL;
}
}

View File

@ -305,17 +305,17 @@ void save_or_free_index_entry(struct index_state *istate, struct cache_entry *ce
}
void replace_index_entry_in_base(struct index_state *istate,
struct cache_entry *old,
struct cache_entry *new)
struct cache_entry *old_entry,
struct cache_entry *new_entry)
{
if (old->index &&
if (old_entry->index &&
istate->split_index &&
istate->split_index->base &&
old->index <= istate->split_index->base->cache_nr) {
new->index = old->index;
if (old != istate->split_index->base->cache[new->index - 1])
free(istate->split_index->base->cache[new->index - 1]);
istate->split_index->base->cache[new->index - 1] = new;
old_entry->index <= istate->split_index->base->cache_nr) {
new_entry->index = old_entry->index;
if (old_entry != istate->split_index->base->cache[new_entry->index - 1])
free(istate->split_index->base->cache[new_entry->index - 1]);
istate->split_index->base->cache[new_entry->index - 1] = new_entry;
}
}

View File

@ -21,7 +21,7 @@ struct split_index *init_split_index(struct index_state *istate);
void save_or_free_index_entry(struct index_state *istate, struct cache_entry *ce);
void replace_index_entry_in_base(struct index_state *istate,
struct cache_entry *old,
struct cache_entry *new);
struct cache_entry *new_entry);
int read_link_extension(struct index_state *istate,
const void *data, unsigned long sz);
int write_link_extension(struct strbuf *sb,

View File

@ -590,7 +590,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule)
{
const struct object_id *old = the_hash_algo->empty_tree, *new = the_hash_algo->empty_tree;
const struct object_id *old_oid = the_hash_algo->empty_tree, *new_oid = the_hash_algo->empty_tree;
struct commit *left = NULL, *right = NULL;
struct commit_list *merge_bases = NULL;
struct child_process cp = CHILD_PROCESS_INIT;
@ -605,9 +605,9 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
goto done;
if (left)
old = one;
old_oid = one;
if (right)
new = two;
new_oid = two;
cp.git_cmd = 1;
cp.dir = path;
@ -630,7 +630,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
argv_array_pushf(&cp.args, "--dst-prefix=%s%s/",
o->b_prefix, path);
}
argv_array_push(&cp.args, oid_to_hex(old));
argv_array_push(&cp.args, oid_to_hex(old_oid));
/*
* If the submodule has modified content, we will diff against the
* work tree, under the assumption that the user has asked for the
@ -638,7 +638,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
* haven't yet been committed to the submodule yet.
*/
if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED))
argv_array_push(&cp.args, oid_to_hex(new));
argv_array_push(&cp.args, oid_to_hex(new_oid));
prepare_submodule_repo_env(&cp.env_array);
if (start_command(&cp))
@ -831,7 +831,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
return 0;
default:
die(_("submodule entry '%s' (%s) is a %s, not a commit"),
cb->path, oid_to_hex(oid), typename(type));
cb->path, oid_to_hex(oid), type_name(type));
}
}
@ -1578,8 +1578,8 @@ static void submodule_reset_index(const char *path)
* pass NULL for old or new respectively.
*/
int submodule_move_head(const char *path,
const char *old,
const char *new,
const char *old_head,
const char *new_head,
unsigned flags)
{
int ret = 0;
@ -1600,7 +1600,7 @@ int submodule_move_head(const char *path,
else
error_code_ptr = NULL;
if (old && !is_submodule_populated_gently(path, error_code_ptr))
if (old_head && !is_submodule_populated_gently(path, error_code_ptr))
return 0;
sub = submodule_from_path(&null_oid, path);
@ -1608,14 +1608,14 @@ int submodule_move_head(const char *path,
if (!sub)
die("BUG: could not get submodule information for '%s'", path);
if (old && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
/* Check if the submodule has a dirty index. */
if (submodule_has_dirty_index(sub))
return error(_("submodule '%s' has dirty index"), path);
}
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
if (old) {
if (old_head) {
if (!submodule_uses_gitfile(path))
absorb_git_dir_into_superproject("", path,
ABSORB_GITDIR_RECURSE_SUBMODULES);
@ -1629,7 +1629,7 @@ int submodule_move_head(const char *path,
submodule_reset_index(path);
}
if (old && (flags & SUBMODULE_MOVE_HEAD_FORCE)) {
if (old_head && (flags & SUBMODULE_MOVE_HEAD_FORCE)) {
char *gitdir = xstrfmt("%s/modules/%s",
get_git_common_dir(), sub->name);
connect_work_tree_and_git_dir(path, gitdir);
@ -1658,9 +1658,9 @@ int submodule_move_head(const char *path,
argv_array_push(&cp.args, "-m");
if (!(flags & SUBMODULE_MOVE_HEAD_FORCE))
argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
argv_array_push(&cp.args, old_head ? old_head : EMPTY_TREE_SHA1_HEX);
argv_array_push(&cp.args, new ? new : EMPTY_TREE_SHA1_HEX);
argv_array_push(&cp.args, new_head ? new_head : EMPTY_TREE_SHA1_HEX);
if (run_command(&cp)) {
ret = -1;
@ -1668,7 +1668,7 @@ int submodule_move_head(const char *path,
}
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
if (new) {
if (new_head) {
child_process_init(&cp);
/* also set the HEAD accordingly */
cp.git_cmd = 1;
@ -1677,7 +1677,7 @@ int submodule_move_head(const char *path,
prepare_submodule_repo_env(&cp.env_array);
argv_array_pushl(&cp.args, "update-ref", "HEAD",
"--no-deref", new, NULL);
"--no-deref", new_head, NULL);
if (run_command(&cp)) {
ret = -1;

View File

@ -117,7 +117,7 @@ int submodule_to_gitdir(struct strbuf *buf, const char *submodule);
#define SUBMODULE_MOVE_HEAD_FORCE (1<<1)
extern int submodule_move_head(const char *path,
const char *old,
const char *new,
const char *new_head,
unsigned flags);
/*

2
tag.c
View File

@ -47,7 +47,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
name_to_report ?
name_to_report :
find_unique_abbrev(oid->hash, DEFAULT_ABBREV),
typename(type));
type_name(type));
buf = read_sha1_file(oid->hash, &type, &size);
if (!buf)

View File

@ -165,11 +165,11 @@ struct tempfile *register_tempfile(const char *path)
return tempfile;
}
struct tempfile *mks_tempfile_sm(const char *template, int suffixlen, int mode)
struct tempfile *mks_tempfile_sm(const char *filename_template, int suffixlen, int mode)
{
struct tempfile *tempfile = new_tempfile();
strbuf_add_absolute_path(&tempfile->filename, template);
strbuf_add_absolute_path(&tempfile->filename, filename_template);
tempfile->fd = git_mkstemps_mode(tempfile->filename.buf, suffixlen, mode);
if (tempfile->fd < 0) {
deactivate_tempfile(tempfile);
@ -179,7 +179,7 @@ struct tempfile *mks_tempfile_sm(const char *template, int suffixlen, int mode)
return tempfile;
}
struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)
struct tempfile *mks_tempfile_tsm(const char *filename_template, int suffixlen, int mode)
{
struct tempfile *tempfile = new_tempfile();
const char *tmpdir;
@ -188,7 +188,7 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)
if (!tmpdir)
tmpdir = "/tmp";
strbuf_addf(&tempfile->filename, "%s/%s", tmpdir, template);
strbuf_addf(&tempfile->filename, "%s/%s", tmpdir, filename_template);
tempfile->fd = git_mkstemps_mode(tempfile->filename.buf, suffixlen, mode);
if (tempfile->fd < 0) {
deactivate_tempfile(tempfile);
@ -198,12 +198,12 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)
return tempfile;
}
struct tempfile *xmks_tempfile_m(const char *template, int mode)
struct tempfile *xmks_tempfile_m(const char *filename_template, int mode)
{
struct tempfile *tempfile;
struct strbuf full_template = STRBUF_INIT;
strbuf_add_absolute_path(&full_template, template);
strbuf_add_absolute_path(&full_template, filename_template);
tempfile = mks_tempfile_m(full_template.buf, mode);
if (!tempfile)
die_errno("Unable to create temporary file '%s'",

View File

@ -135,58 +135,58 @@ extern struct tempfile *register_tempfile(const char *path);
*/
/* See "mks_tempfile functions" above. */
extern struct tempfile *mks_tempfile_sm(const char *template,
extern struct tempfile *mks_tempfile_sm(const char *filename_template,
int suffixlen, int mode);
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile_s(const char *template,
static inline struct tempfile *mks_tempfile_s(const char *filename_template,
int suffixlen)
{
return mks_tempfile_sm(template, suffixlen, 0600);
return mks_tempfile_sm(filename_template, suffixlen, 0600);
}
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile_m(const char *template, int mode)
static inline struct tempfile *mks_tempfile_m(const char *filename_template, int mode)
{
return mks_tempfile_sm(template, 0, mode);
return mks_tempfile_sm(filename_template, 0, mode);
}
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile(const char *template)
static inline struct tempfile *mks_tempfile(const char *filename_template)
{
return mks_tempfile_sm(template, 0, 0600);
return mks_tempfile_sm(filename_template, 0, 0600);
}
/* See "mks_tempfile functions" above. */
extern struct tempfile *mks_tempfile_tsm(const char *template,
extern struct tempfile *mks_tempfile_tsm(const char *filename_template,
int suffixlen, int mode);
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile_ts(const char *template,
static inline struct tempfile *mks_tempfile_ts(const char *filename_template,
int suffixlen)
{
return mks_tempfile_tsm(template, suffixlen, 0600);
return mks_tempfile_tsm(filename_template, suffixlen, 0600);
}
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile_tm(const char *template, int mode)
static inline struct tempfile *mks_tempfile_tm(const char *filename_template, int mode)
{
return mks_tempfile_tsm(template, 0, mode);
return mks_tempfile_tsm(filename_template, 0, mode);
}
/* See "mks_tempfile functions" above. */
static inline struct tempfile *mks_tempfile_t(const char *template)
static inline struct tempfile *mks_tempfile_t(const char *filename_template)
{
return mks_tempfile_tsm(template, 0, 0600);
return mks_tempfile_tsm(filename_template, 0, 0600);
}
/* See "mks_tempfile functions" above. */
extern struct tempfile *xmks_tempfile_m(const char *template, int mode);
extern struct tempfile *xmks_tempfile_m(const char *filename_template, int mode);
/* See "mks_tempfile functions" above. */
static inline struct tempfile *xmks_tempfile(const char *template)
static inline struct tempfile *xmks_tempfile(const char *filename_template)
{
return xmks_tempfile_m(template, 0600);
return xmks_tempfile_m(filename_template, 0600);
}
/*

View File

@ -174,12 +174,12 @@ static void print_all(FILE *outfile, struct list_head *head,
static struct trailer_item *trailer_from_arg(struct arg_item *arg_tok)
{
struct trailer_item *new = xcalloc(sizeof(*new), 1);
new->token = arg_tok->token;
new->value = arg_tok->value;
struct trailer_item *new_item = xcalloc(sizeof(*new_item), 1);
new_item->token = arg_tok->token;
new_item->value = arg_tok->value;
arg_tok->token = arg_tok->value = NULL;
free_arg_item(arg_tok);
return new;
return new_item;
}
static void add_arg_to_input_list(struct trailer_item *on_tok,
@ -666,30 +666,30 @@ static void parse_trailer(struct strbuf *tok, struct strbuf *val,
static struct trailer_item *add_trailer_item(struct list_head *head, char *tok,
char *val)
{
struct trailer_item *new = xcalloc(sizeof(*new), 1);
new->token = tok;
new->value = val;
list_add_tail(&new->list, head);
return new;
struct trailer_item *new_item = xcalloc(sizeof(*new_item), 1);
new_item->token = tok;
new_item->value = val;
list_add_tail(&new_item->list, head);
return new_item;
}
static void add_arg_item(struct list_head *arg_head, char *tok, char *val,
const struct conf_info *conf,
const struct new_trailer_item *new_trailer_item)
{
struct arg_item *new = xcalloc(sizeof(*new), 1);
new->token = tok;
new->value = val;
duplicate_conf(&new->conf, conf);
struct arg_item *new_item = xcalloc(sizeof(*new_item), 1);
new_item->token = tok;
new_item->value = val;
duplicate_conf(&new_item->conf, conf);
if (new_trailer_item) {
if (new_trailer_item->where != WHERE_DEFAULT)
new->conf.where = new_trailer_item->where;
new_item->conf.where = new_trailer_item->where;
if (new_trailer_item->if_exists != EXISTS_DEFAULT)
new->conf.if_exists = new_trailer_item->if_exists;
new_item->conf.if_exists = new_trailer_item->if_exists;
if (new_trailer_item->if_missing != MISSING_DEFAULT)
new->conf.if_missing = new_trailer_item->if_missing;
new_item->conf.if_missing = new_trailer_item->if_missing;
}
list_add_tail(&new->list, arg_head);
list_add_tail(&new_item->list, arg_head);
}
static void process_command_line_args(struct list_head *arg_head,
@ -1000,7 +1000,7 @@ static struct tempfile *trailers_tempfile;
static FILE *create_in_place_tempfile(const char *file)
{
struct stat st;
struct strbuf template = STRBUF_INIT;
struct strbuf filename_template = STRBUF_INIT;
const char *tail;
FILE *outfile;
@ -1014,11 +1014,11 @@ static FILE *create_in_place_tempfile(const char *file)
/* Create temporary file in the same directory as the original */
tail = strrchr(file, '/');
if (tail != NULL)
strbuf_add(&template, file, tail - file + 1);
strbuf_addstr(&template, "git-interpret-trailers-XXXXXX");
strbuf_add(&filename_template, file, tail - file + 1);
strbuf_addstr(&filename_template, "git-interpret-trailers-XXXXXX");
trailers_tempfile = xmks_tempfile_m(template.buf, st.st_mode);
strbuf_release(&template);
trailers_tempfile = xmks_tempfile_m(filename_template.buf, st.st_mode);
strbuf_release(&filename_template);
outfile = fdopen_tempfile(trailers_tempfile, "w");
if (!outfile)
die_errno(_("could not open temporary file"));

View File

@ -195,10 +195,10 @@ static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
static struct cache_entry *dup_entry(const struct cache_entry *ce)
{
unsigned int size = ce_size(ce);
struct cache_entry *new = xmalloc(size);
struct cache_entry *new_entry = xmalloc(size);
memcpy(new, ce, size);
return new;
memcpy(new_entry, ce, size);
return new_entry;
}
static void add_entry(struct unpack_trees_options *o,

View File

@ -22,7 +22,7 @@ void walker_say(struct walker *walker, const char *fmt, ...)
static void report_missing(const struct object *obj)
{
fprintf(stderr, "Cannot obtain needed %s %s\n",
obj->type ? typename(obj->type): "object",
obj->type ? type_name(obj->type): "object",
oid_to_hex(&obj->oid));
if (!is_null_oid(&current_commit_oid))
fprintf(stderr, "while processing commit %s.\n",
@ -134,7 +134,7 @@ static int process_object(struct walker *walker, struct object *obj)
}
return error("Unable to determine requirements "
"of type %s for %s",
typename(obj->type), oid_to_hex(&obj->oid));
type_name(obj->type), oid_to_hex(&obj->oid));
}
static int process(struct walker *walker, struct object *obj)

View File

@ -445,21 +445,21 @@ FILE *fopen_or_warn(const char *path, const char *mode)
return NULL;
}
int xmkstemp(char *template)
int xmkstemp(char *filename_template)
{
int fd;
char origtemplate[PATH_MAX];
strlcpy(origtemplate, template, sizeof(origtemplate));
strlcpy(origtemplate, filename_template, sizeof(origtemplate));
fd = mkstemp(template);
fd = mkstemp(filename_template);
if (fd < 0) {
int saved_errno = errno;
const char *nonrelative_template;
if (strlen(template) != strlen(origtemplate))
template = origtemplate;
if (strlen(filename_template) != strlen(origtemplate))
filename_template = origtemplate;
nonrelative_template = absolute_path(template);
nonrelative_template = absolute_path(filename_template);
errno = saved_errno;
die_errno("Unable to create temporary file '%s'",
nonrelative_template);
@ -481,7 +481,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
static const int num_letters = 62;
uint64_t value;
struct timeval tv;
char *template;
char *filename_template;
size_t len;
int fd, count;
@ -503,16 +503,16 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
*/
gettimeofday(&tv, NULL);
value = ((size_t)(tv.tv_usec << 16)) ^ tv.tv_sec ^ getpid();
template = &pattern[len - 6 - suffix_len];
filename_template = &pattern[len - 6 - suffix_len];
for (count = 0; count < TMP_MAX; ++count) {
uint64_t v = value;
/* Fill in the random bits. */
template[0] = letters[v % num_letters]; v /= num_letters;
template[1] = letters[v % num_letters]; v /= num_letters;
template[2] = letters[v % num_letters]; v /= num_letters;
template[3] = letters[v % num_letters]; v /= num_letters;
template[4] = letters[v % num_letters]; v /= num_letters;
template[5] = letters[v % num_letters]; v /= num_letters;
filename_template[0] = letters[v % num_letters]; v /= num_letters;
filename_template[1] = letters[v % num_letters]; v /= num_letters;
filename_template[2] = letters[v % num_letters]; v /= num_letters;
filename_template[3] = letters[v % num_letters]; v /= num_letters;
filename_template[4] = letters[v % num_letters]; v /= num_letters;
filename_template[5] = letters[v % num_letters]; v /= num_letters;
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
if (fd >= 0)
@ -541,21 +541,21 @@ int git_mkstemp_mode(char *pattern, int mode)
return git_mkstemps_mode(pattern, 0, mode);
}
int xmkstemp_mode(char *template, int mode)
int xmkstemp_mode(char *filename_template, int mode)
{
int fd;
char origtemplate[PATH_MAX];
strlcpy(origtemplate, template, sizeof(origtemplate));
strlcpy(origtemplate, filename_template, sizeof(origtemplate));
fd = git_mkstemp_mode(template, mode);
fd = git_mkstemp_mode(filename_template, mode);
if (fd < 0) {
int saved_errno = errno;
const char *nonrelative_template;
if (!template[0])
template = origtemplate;
if (!filename_template[0])
filename_template = origtemplate;
nonrelative_template = absolute_path(template);
nonrelative_template = absolute_path(filename_template);
errno = saved_errno;
die_errno("Unable to create temporary file '%s'",
nonrelative_template);