mirror of https://github.com/git/git.git
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:
commit
169c9c0169
122
apply.c
122
apply.c
|
@ -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
33
blame.c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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 |