Skip to content

Commit 2d5792f

Browse files
committed
Merge branch 'bw/c-plus-plus' into ds/lazy-load-trees
* 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 ...
2 parents 7547b95 + efdfe11 commit 2d5792f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+663
-662
lines changed

apply.c

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage,
23012301
size_t len, size_t postlen)
23022302
{
23032303
int i, ctx, reduced;
2304-
char *new, *old, *fixed;
2304+
char *new_buf, *old_buf, *fixed;
23052305
struct image fixed_preimage;
23062306

23072307
/*
@@ -2327,25 +2327,25 @@ static void update_pre_post_images(struct image *preimage,
23272327
* We trust the caller to tell us if the update can be done
23282328
* in place (postlen==0) or not.
23292329
*/
2330-
old = postimage->buf;
2330+
old_buf = postimage->buf;
23312331
if (postlen)
2332-
new = postimage->buf = xmalloc(postlen);
2332+
new_buf = postimage->buf = xmalloc(postlen);
23332333
else
2334-
new = old;
2334+
new_buf = old_buf;
23352335
fixed = preimage->buf;
23362336

23372337
for (i = reduced = ctx = 0; i < postimage->nr; i++) {
23382338
size_t l_len = postimage->line[i].len;
23392339
if (!(postimage->line[i].flag & LINE_COMMON)) {
23402340
/* an added line -- no counterparts in preimage */
2341-
memmove(new, old, l_len);
2342-
old += l_len;
2343-
new += l_len;
2341+
memmove(new_buf, old_buf, l_len);
2342+
old_buf += l_len;
2343+
new_buf += l_len;
23442344
continue;
23452345
}
23462346

23472347
/* a common context -- skip it in the original postimage */
2348-
old += l_len;
2348+
old_buf += l_len;
23492349

23502350
/* and find the corresponding one in the fixed preimage */
23512351
while (ctx < preimage->nr &&
@@ -2365,29 +2365,29 @@ static void update_pre_post_images(struct image *preimage,
23652365

23662366
/* and copy it in, while fixing the line length */
23672367
l_len = preimage->line[ctx].len;
2368-
memcpy(new, fixed, l_len);
2369-
new += l_len;
2368+
memcpy(new_buf, fixed, l_len);
2369+
new_buf += l_len;
23702370
fixed += l_len;
23712371
postimage->line[i].len = l_len;
23722372
ctx++;
23732373
}
23742374

23752375
if (postlen
2376-
? postlen < new - postimage->buf
2377-
: postimage->len < new - postimage->buf)
2376+
? postlen < new_buf - postimage->buf
2377+
: postimage->len < new_buf - postimage->buf)
23782378
die("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d",
2379-
(int)postlen, (int) postimage->len, (int)(new - postimage->buf));
2379+
(int)postlen, (int) postimage->len, (int)(new_buf - postimage->buf));
23802380

23812381
/* Fix the length of the whole thing */
2382-
postimage->len = new - postimage->buf;
2382+
postimage->len = new_buf - postimage->buf;
23832383
postimage->nr -= reduced;
23842384
}
23852385

23862386
static int line_by_line_fuzzy_match(struct image *img,
23872387
struct image *preimage,
23882388
struct image *postimage,
2389-
unsigned long try,
2390-
int try_lno,
2389+
unsigned long current,
2390+
int current_lno,
23912391
int preimage_limit)
23922392
{
23932393
int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,
24042404

24052405
for (i = 0; i < preimage_limit; i++) {
24062406
size_t prelen = preimage->line[i].len;
2407-
size_t imglen = img->line[try_lno+i].len;
2407+
size_t imglen = img->line[current_lno+i].len;
24082408

2409-
if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
2409+
if (!fuzzy_matchlines(img->buf + current + imgoff, imglen,
24102410
preimage->buf + preoff, prelen))
24112411
return 0;
24122412
if (preimage->line[i].flag & LINE_COMMON)
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,
24432443
*/
24442444
extra_chars = preimage_end - preimage_eof;
24452445
strbuf_init(&fixed, imgoff + extra_chars);
2446-
strbuf_add(&fixed, img->buf + try, imgoff);
2446+
strbuf_add(&fixed, img->buf + current, imgoff);
24472447
strbuf_add(&fixed, preimage_eof, extra_chars);
24482448
fixed_buf = strbuf_detach(&fixed, &fixed_len);
24492449
update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,
24552455
struct image *img,
24562456
struct image *preimage,
24572457
struct image *postimage,
2458-
unsigned long try,
2459-
int try_lno,
2458+
unsigned long current,
2459+
int current_lno,
24602460
unsigned ws_rule,
24612461
int match_beginning, int match_end)
24622462
{
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,
24662466
size_t fixed_len, postlen;
24672467
int preimage_limit;
24682468

2469-
if (preimage->nr + try_lno <= img->nr) {
2469+
if (preimage->nr + current_lno <= img->nr) {
24702470
/*
24712471
* The hunk falls within the boundaries of img.
24722472
*/
24732473
preimage_limit = preimage->nr;
2474-
if (match_end && (preimage->nr + try_lno != img->nr))
2474+
if (match_end && (preimage->nr + current_lno != img->nr))
24752475
return 0;
24762476
} else if (state->ws_error_action == correct_ws_error &&
24772477
(ws_rule & WS_BLANK_AT_EOF)) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,
24822482
* match with img, and the remainder of the preimage
24832483
* must be blank.
24842484
*/
2485-
preimage_limit = img->nr - try_lno;
2485+
preimage_limit = img->nr - current_lno;
24862486
} else {
24872487
/*
24882488
* The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,
24922492
return 0;
24932493
}
24942494

2495-
if (match_beginning && try_lno)
2495+
if (match_beginning && current_lno)
24962496
return 0;
24972497

24982498
/* Quick hash check */
24992499
for (i = 0; i < preimage_limit; i++)
2500-
if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
2501-
(preimage->line[i].hash != img->line[try_lno + i].hash))
2500+
if ((img->line[current_lno + i].flag & LINE_PATCHED) ||
2501+
(preimage->line[i].hash != img->line[current_lno + i].hash))
25022502
return 0;
25032503

25042504
if (preimage_limit == preimage->nr) {
25052505
/*
25062506
* Do we have an exact match? If we were told to match
2507-
* at the end, size must be exactly at try+fragsize,
2508-
* otherwise try+fragsize must be still within the preimage,
2507+
* at the end, size must be exactly at current+fragsize,
2508+
* otherwise current+fragsize must be still within the preimage,
25092509
* and either case, the old piece should match the preimage
25102510
* exactly.
25112511
*/
25122512
if ((match_end
2513-
? (try + preimage->len == img->len)
2514-
: (try + preimage->len <= img->len)) &&
2515-
!memcmp(img->buf + try, preimage->buf, preimage->len))
2513+
? (current + preimage->len == img->len)
2514+
: (current + preimage->len <= img->len)) &&
2515+
!memcmp(img->buf + current, preimage->buf, preimage->len))
25162516
return 1;
25172517
} else {
25182518
/*
@@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,
25432543
*/
25442544
if (state->ws_ignore_action == ignore_ws_change)
25452545
return line_by_line_fuzzy_match(img, preimage, postimage,
2546-
try, try_lno, preimage_limit);
2546+
current, current_lno, preimage_limit);
25472547

25482548
if (state->ws_error_action != correct_ws_error)
25492549
return 0;
@@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,
25772577
*/
25782578
strbuf_init(&fixed, preimage->len + 1);
25792579
orig = preimage->buf;
2580-
target = img->buf + try;
2580+
target = img->buf + current;
25812581
for (i = 0; i < preimage_limit; i++) {
25822582
size_t oldlen = preimage->line[i].len;
2583-
size_t tgtlen = img->line[try_lno + i].len;
2583+
size_t tgtlen = img->line[current_lno + i].len;
25842584
size_t fixstart = fixed.len;
25852585
struct strbuf tgtfix;
25862586
int match;
@@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state,
26662666
int match_beginning, int match_end)
26672667
{
26682668
int i;
2669-
unsigned long backwards, forwards, try;
2670-
int backwards_lno, forwards_lno, try_lno;
2669+
unsigned long backwards, forwards, current;
2670+
int backwards_lno, forwards_lno, current_lno;
26712671

26722672
/*
26732673
* If match_beginning or match_end is specified, there is no
@@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,
26872687
if ((size_t) line > img->nr)
26882688
line = img->nr;
26892689

2690-
try = 0;
2690+
current = 0;
26912691
for (i = 0; i < line; i++)
2692-
try += img->line[i].len;
2692+
current += img->line[i].len;
26932693

26942694
/*
26952695
* There's probably some smart way to do this, but I'll leave
26962696
* that to the smart and beautiful people. I'm simple and stupid.
26972697
*/
2698-
backwards = try;
2698+
backwards = current;
26992699
backwards_lno = line;
2700-
forwards = try;
2700+
forwards = current;
27012701
forwards_lno = line;
2702-
try_lno = line;
2702+
current_lno = line;
27032703

27042704
for (i = 0; ; i++) {
27052705
if (match_fragment(state, img, preimage, postimage,
2706-
try, try_lno, ws_rule,
2706+
current, current_lno, ws_rule,
27072707
match_beginning, match_end))
2708-
return try_lno;
2708+
return current_lno;
27092709

27102710
again:
27112711
if (backwards_lno == 0 && forwards_lno == img->nr)
@@ -2718,17 +2718,17 @@ static int find_pos(struct apply_state *state,
27182718
}
27192719
backwards_lno--;
27202720
backwards -= img->line[backwards_lno].len;
2721-
try = backwards;
2722-
try_lno = backwards_lno;
2721+
current = backwards;
2722+
current_lno = backwards_lno;
27232723
} else {
27242724
if (forwards_lno == img->nr) {
27252725
i++;
27262726
goto again;
27272727
}
27282728
forwards += img->line[forwards_lno].len;
27292729
forwards_lno++;
2730-
try = forwards;
2731-
try_lno = forwards_lno;
2730+
current = forwards;
2731+
current_lno = forwards_lno;
27322732
}
27332733

27342734
}
@@ -4163,30 +4163,30 @@ static void show_mode_change(struct patch *p, int show_name)
41634163
static void show_rename_copy(struct patch *p)
41644164
{
41654165
const char *renamecopy = p->is_rename ? "rename" : "copy";
4166-
const char *old, *new;
4166+
const char *old_name, *new_name;
41674167

41684168
/* Find common prefix */
4169-
old = p->old_name;
4170-
new = p->new_name;
4169+
old_name = p->old_name;
4170+
new_name = p->new_name;
41714171
while (1) {
41724172
const char *slash_old, *slash_new;
4173-
slash_old = strchr(old, '/');
4174-
slash_new = strchr(new, '/');
4173+
slash_old = strchr(old_name, '/');
4174+
slash_new = strchr(new_name, '/');
41754175
if (!slash_old ||
41764176
!slash_new ||
4177-
slash_old - old != slash_new - new ||
4178-
memcmp(old, new, slash_new - new))
4177+
slash_old - old_name != slash_new - new_name ||
4178+
memcmp(old_name, new_name, slash_new - new_name))
41794179
break;
4180-
old = slash_old + 1;
4181-
new = slash_new + 1;
4180+
old_name = slash_old + 1;
4181+
new_name = slash_new + 1;
41824182
}
4183-
/* p->old_name thru old is the common prefix, and old and new
4183+
/* p->old_name thru old_name is the common prefix, and old_name and new_name
41844184
* through the end of names are renames
41854185
*/
4186-
if (old != p->old_name)
4186+
if (old_name != p->old_name)
41874187
printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
4188-
(int)(old - p->old_name), p->old_name,
4189-
old, new, p->score);
4188+
(int)(old_name - p->old_name), p->old_name,
4189+
old_name, new_name, p->score);
41904190
else
41914191
printf(" %s %s => %s (%d%%)\n", renamecopy,
41924192
p->old_name, p->new_name, p->score);

blame.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -998,28 +998,29 @@ unsigned blame_entry_score(struct blame_scoreboard *sb, struct blame_entry *e)
998998
}
999999

10001000
/*
1001-
* best_so_far[] and this[] are both a split of an existing blame_entry
1002-
* that passes blame to the parent. Maintain best_so_far the best split
1003-
* so far, by comparing this and best_so_far and copying this into
1001+
* best_so_far[] and potential[] are both a split of an existing blame_entry
1002+
* that passes blame to the parent. Maintain best_so_far the best split so
1003+
* far, by comparing potential and best_so_far and copying potential into
10041004
* bst_so_far as needed.
10051005
*/
10061006
static void copy_split_if_better(struct blame_scoreboard *sb,
10071007
struct blame_entry *best_so_far,
1008-
struct blame_entry *this)
1008+
struct blame_entry *potential)
10091009
{
10101010
int i;
10111011

1012-
if (!this[1].suspect)
1012+
if (!potential[1].suspect)
10131013
return;
10141014
if (best_so_far[1].suspect) {
1015-
if (blame_entry_score(sb, &this[1]) < blame_entry_score(sb, &best_so_far[1]))
1015+
if (blame_entry_score(sb, &potential[1]) <
1016+
blame_entry_score(sb, &best_so_far[1]))
10161017
return;
10171018
}
10181019

10191020
for (i = 0; i < 3; i++)
1020-
blame_origin_incref(this[i].suspect);
1021+
blame_origin_incref(potential[i].suspect);
10211022
decref_split(best_so_far);
1022-
memcpy(best_so_far, this, sizeof(struct blame_entry [3]));
1023+
memcpy(best_so_far, potential, sizeof(struct blame_entry[3]));
10231024
}
10241025

10251026
/*
@@ -1046,12 +1047,12 @@ static void handle_split(struct blame_scoreboard *sb,
10461047
if (ent->num_lines <= tlno)
10471048
return;
10481049
if (tlno < same) {
1049-
struct blame_entry this[3];
1050+
struct blame_entry potential[3];
10501051
tlno += ent->s_lno;
10511052
same += ent->s_lno;
1052-
split_overlap(this, ent, tlno, plno, same, parent);
1053-
copy_split_if_better(sb, split, this);
1054-
decref_split(this);
1053+
split_overlap(potential, ent, tlno, plno, same, parent);
1054+
copy_split_if_better(sb, split, potential);
1055+
decref_split(potential);
10551056
}
10561057
}
10571058

@@ -1273,7 +1274,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
12731274
struct diff_filepair *p = diff_queued_diff.queue[i];
12741275
struct blame_origin *norigin;
12751276
mmfile_t file_p;
1276-
struct blame_entry this[3];
1277+
struct blame_entry potential[3];
12771278

12781279
if (!DIFF_FILE_VALID(p->one))
12791280
continue; /* does not exist in parent */
@@ -1292,10 +1293,10 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
12921293

12931294
for (j = 0; j < num_ents; j++) {
12941295
find_copy_in_blob(sb, blame_list[j].ent,
1295-
norigin, this, &file_p);
1296+
norigin, potential, &file_p);
12961297
copy_split_if_better(sb, blame_list[j].split,
1297-
this);
1298-
decref_split(this);
1298+
potential);
1299+
decref_split(potential);
12991300
}
13001301
blame_origin_decref(norigin);
13011302
}

builtin/cat-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
7676
buf = NULL;
7777
switch (opt) {
7878
case 't':
79-
oi.typename = &sb;
79+
oi.type_name = &sb;
8080
if (sha1_object_info_extended(oid.hash, &oi, flags) < 0)
8181
die("git cat-file: could not get object info");
8282
if (sb.len) {
@@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
229229
if (data->mark_query)
230230
data->info.typep = &data->type;
231231
else
232-
strbuf_addstr(sb, typename(data->type));
232+
strbuf_addstr(sb, type_name(data->type));
233233
} else if (is_atom("objectsize", atom, len)) {
234234
if (data->mark_query)
235235
data->info.sizep = &data->size;

0 commit comments

Comments
 (0)