Skip to content

Commit 96aa7ad

Browse files
committed
Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0: 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 branch: die explicitly why when calling "git branch [-a|-r] branchname".
2 parents 70d7099 + 0606c36 commit 96aa7ad

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
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-branch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
583583
rename_branch(head, argv[0], rename > 1);
584584
else if (rename && (argc == 2))
585585
rename_branch(argv[0], argv[1], rename > 1);
586-
else if (argc <= 2)
586+
else if (argc <= 2) {
587+
if (kinds != REF_LOCAL_BRANCH)
588+
die("-a and -r options to 'git branch' do not make sense with a branch name");
587589
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
588590
force_create, reflog, track);
589-
else
591+
} else
590592
usage_with_options(builtin_branch_usage, options);
591593

592594
return 0;

builtin-checkout.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int merge_working_tree(struct checkout_opts *opts,
403403
topts.initial_checkout = is_cache_unborn();
404404
topts.update = 1;
405405
topts.merge = 1;
406-
topts.gently = opts->merge;
406+
topts.gently = opts->merge && old->commit;
407407
topts.verbose_update = !opts->quiet;
408408
topts.fn = twoway_merge;
409409
topts.dir = xcalloc(1, sizeof(*topts.dir));
@@ -426,7 +426,13 @@ static int merge_working_tree(struct checkout_opts *opts,
426426
struct merge_options o;
427427
if (!opts->merge)
428428
return 1;
429-
parse_commit(old->commit);
429+
430+
/*
431+
* Without old->commit, the below is the same as
432+
* the two-tree unpack we already tried and failed.
433+
*/
434+
if (!old->commit)
435+
return 1;
430436

431437
/* Do more real merge */
432438

t/t5403-post-checkout-hook.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ test_description='Test the post-checkout hook.'
77
. ./test-lib.sh
88

99
test_expect_success setup '
10-
echo Data for commit0. >a &&
11-
echo Data for commit0. >b &&
12-
git update-index --add a &&
13-
git update-index --add b &&
14-
tree0=$(git write-tree) &&
15-
commit0=$(echo setup | git commit-tree $tree0) &&
16-
git update-ref refs/heads/master $commit0 &&
17-
git clone ./. clone1 &&
18-
git clone ./. clone2 &&
19-
GIT_DIR=clone2/.git git branch -a new2 &&
20-
echo Data for commit1. >clone2/b &&
21-
GIT_DIR=clone2/.git git add clone2/b &&
22-
GIT_DIR=clone2/.git git commit -m new2
10+
echo Data for commit0. >a &&
11+
echo Data for commit0. >b &&
12+
git update-index --add a &&
13+
git update-index --add b &&
14+
tree0=$(git write-tree) &&
15+
commit0=$(echo setup | git commit-tree $tree0) &&
16+
git update-ref refs/heads/master $commit0 &&
17+
git clone ./. clone1 &&
18+
git clone ./. clone2 &&
19+
GIT_DIR=clone2/.git git branch new2 &&
20+
echo Data for commit1. >clone2/b &&
21+
GIT_DIR=clone2/.git git add clone2/b &&
22+
GIT_DIR=clone2/.git git commit -m new2
2323
'
2424

2525
for clone in 1 2; do

0 commit comments

Comments
 (0)