Skip to content

Commit 8fb5d44

Browse files
committed
Merge branch 'maint-1.6.2' into maint
* maint-1.6.2: base85: Make the code more obvious instead of explaining the non-obvious base85: encode_85() does not use the decode table base85 debug code: Fix length byte calculation checkout -m: do not try to fall back to --merge from an unborn branch Conflicts: diff.c
2 parents 578b62b + c503467 commit 8fb5d44

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

base85.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len)
5757
de = de85[ch];
5858
if (--de < 0)
5959
return error("invalid base85 alphabet %c", ch);
60-
/*
61-
* Detect overflow. The largest
62-
* 5-letter possible is "|NsC0" to
63-
* encode 0xffffffff, and "|NsC" gives
64-
* 0x03030303 at this point (i.e.
65-
* 0xffffffff = 0x03030303 * 85).
66-
*/
67-
if (0x03030303 < acc ||
60+
/* Detect overflow. */
61+
if (0xffffffff / 85 < acc ||
6862
0xffffffff - de < (acc *= 85))
6963
return error("invalid base85 sequence %.5s", buffer-5);
7064
acc += de;
@@ -84,8 +78,6 @@ int decode_85(char *dst, const char *buffer, int len)
8478

8579
void encode_85(char *buf, const unsigned char *data, int bytes)
8680
{
87-
prep_base85();
88-
8981
say("encode 85");
9082
while (bytes) {
9183
unsigned acc = 0;
@@ -118,7 +110,7 @@ int main(int ac, char **av)
118110
int len = strlen(av[2]);
119111
encode_85(buf, av[2], len);
120112
if (len <= 26) len = len + 'A' - 1;
121-
else len = len + 'a' - 26 + 1;
113+
else len = len + 'a' - 26 - 1;
122114
printf("encoded: %c%s\n", len, buf);
123115
return 0;
124116
}

builtin-checkout.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts,
397397
topts.initial_checkout = is_cache_unborn();
398398
topts.update = 1;
399399
topts.merge = 1;
400-
topts.gently = opts->merge;
400+
topts.gently = opts->merge && old->commit;
401401
topts.verbose_update = !opts->quiet;
402402
topts.fn = twoway_merge;
403403
topts.dir = xcalloc(1, sizeof(*topts.dir));
@@ -422,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts,
422422
struct merge_options o;
423423
if (!opts->merge)
424424
return 1;
425-
parse_commit(old->commit);
425+
426+
/*
427+
* Without old->commit, the below is the same as
428+
* the two-tree unpack we already tried and failed.
429+
*/
430+
if (!old->commit)
431+
return 1;
426432

427433
/* Do more real merge */
428434

0 commit comments

Comments
 (0)