Browse Source

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
maint
Junio C Hamano 15 years ago
parent
commit
8fb5d44a47
  1. 14
      base85.c
  2. 10
      builtin-checkout.c

14
base85.c

@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len) @@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len)
de = de85[ch];
if (--de < 0)
return error("invalid base85 alphabet %c", ch);
/*
* Detect overflow. The largest
* 5-letter possible is "|NsC0" to
* encode 0xffffffff, and "|NsC" gives
* 0x03030303 at this point (i.e.
* 0xffffffff = 0x03030303 * 85).
*/
if (0x03030303 < acc ||
/* Detect overflow. */
if (0xffffffff / 85 < acc ||
0xffffffff - de < (acc *= 85))
return error("invalid base85 sequence %.5s", buffer-5);
acc += de;
@ -84,8 +78,6 @@ int decode_85(char *dst, const char *buffer, int len) @@ -84,8 +78,6 @@ int decode_85(char *dst, const char *buffer, int len)

void encode_85(char *buf, const unsigned char *data, int bytes)
{
prep_base85();

say("encode 85");
while (bytes) {
unsigned acc = 0;
@ -118,7 +110,7 @@ int main(int ac, char **av) @@ -118,7 +110,7 @@ int main(int ac, char **av)
int len = strlen(av[2]);
encode_85(buf, av[2], len);
if (len <= 26) len = len + 'A' - 1;
else len = len + 'a' - 26 + 1;
else len = len + 'a' - 26 - 1;
printf("encoded: %c%s\n", len, buf);
return 0;
}

10
builtin-checkout.c

@ -397,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts, @@ -397,7 +397,7 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.initial_checkout = is_cache_unborn();
topts.update = 1;
topts.merge = 1;
topts.gently = opts->merge;
topts.gently = opts->merge && old->commit;
topts.verbose_update = !opts->quiet;
topts.fn = twoway_merge;
topts.dir = xcalloc(1, sizeof(*topts.dir));
@ -422,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts, @@ -422,7 +422,13 @@ static int merge_working_tree(struct checkout_opts *opts,
struct merge_options o;
if (!opts->merge)
return 1;
parse_commit(old->commit);

/*
* Without old->commit, the below is the same as
* the two-tree unpack we already tried and failed.
*/
if (!old->commit)
return 1;

/* Do more real merge */


Loading…
Cancel
Save