Skip to content

Commit 011c181

Browse files
committed
Merge branch 'maint-1.6.2' into maint-1.6.3
* 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 branch: die explicitly why when calling "git branch [-a|-r] branchname". textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Conflicts: diff.c
2 parents ba7e814 + c503467 commit 011c181

File tree

8 files changed

+47
-43
lines changed

8 files changed

+47
-43
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
@@ -634,10 +634,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
634634
rename_branch(head, argv[0], rename > 1);
635635
else if (rename && (argc == 2))
636636
rename_branch(argv[0], argv[1], rename > 1);
637-
else if (argc <= 2)
637+
else if (argc <= 2) {
638+
if (kinds != REF_LOCAL_BRANCH)
639+
die("-a and -r options to 'git branch' do not make sense with a branch name");
638640
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
639641
force_create, reflog, track);
640-
else
642+
} else
641643
usage_with_options(builtin_branch_usage, options);
642644

643645
return 0;

builtin-checkout.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int merge_working_tree(struct checkout_opts *opts,
396396
topts.initial_checkout = is_cache_unborn();
397397
topts.update = 1;
398398
topts.merge = 1;
399-
topts.gently = opts->merge;
399+
topts.gently = opts->merge && old->commit;
400400
topts.verbose_update = !opts->quiet;
401401
topts.fn = twoway_merge;
402402
topts.dir = xcalloc(1, sizeof(*topts.dir));
@@ -419,7 +419,13 @@ static int merge_working_tree(struct checkout_opts *opts,
419419
struct merge_options o;
420420
if (!opts->merge)
421421
return 1;
422-
parse_commit(old->commit);
422+
423+
/*
424+
* Without old->commit, the below is the same as
425+
* the two-tree unpack we already tried and failed.
426+
*/
427+
if (!old->commit)
428+
return 1;
423429

424430
/* Do more real merge */
425431

builtin-commit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
8686
static struct option builtin_commit_options[] = {
8787
OPT__QUIET(&quiet),
8888
OPT__VERBOSE(&verbose),
89-
OPT_GROUP("Commit message options"),
9089

90+
OPT_GROUP("Commit message options"),
9191
OPT_STRING('F', "file", &logfile, "FILE", "read log from file"),
9292
OPT_STRING(0, "author", &force_author, "AUTHOR", "override author for commit"),
9393
OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m),
@@ -96,6 +96,8 @@ static struct option builtin_commit_options[] = {
9696
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
9797
OPT_STRING('t', "template", &template_file, "FILE", "use specified template file"),
9898
OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
99+
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
100+
/* end commit message options */
99101

100102
OPT_GROUP("Commit contents options"),
101103
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
@@ -106,7 +108,7 @@ static struct option builtin_commit_options[] = {
106108
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
107109
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
108110
OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
109-
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
111+
/* end commit contents options */
110112

111113
OPT_END()
112114
};

builtin-count-objects.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
static void count_objects(DIR *d, char *path, int len, int verbose,
1313
unsigned long *loose,
14-
unsigned long *loose_size,
14+
off_t *loose_size,
1515
unsigned long *packed_loose,
1616
unsigned long *garbage)
1717
{
@@ -77,7 +77,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
7777
int len = strlen(objdir);
7878
char *path = xmalloc(len + 50);
7979
unsigned long loose = 0, packed = 0, packed_loose = 0, garbage = 0;
80-
unsigned long loose_size = 0;
80+
off_t loose_size = 0;
8181
struct option opts[] = {
8282
OPT__VERBOSE(&verbose),
8383
OPT_END(),
@@ -103,7 +103,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
103103
if (verbose) {
104104
struct packed_git *p;
105105
unsigned long num_pack = 0;
106-
unsigned long size_pack = 0;
106+
off_t size_pack = 0;
107107
if (!packed_git)
108108
prepare_packed_git();
109109
for (p = packed_git; p; p = p->next) {
@@ -116,15 +116,15 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
116116
num_pack++;
117117
}
118118
printf("count: %lu\n", loose);
119-
printf("size: %lu\n", loose_size / 1024);
119+
printf("size: %lu\n", (unsigned long) (loose_size / 1024));
120120
printf("in-pack: %lu\n", packed);
121121
printf("packs: %lu\n", num_pack);
122-
printf("size-pack: %lu\n", size_pack / 1024);
122+
printf("size-pack: %lu\n", (unsigned long) (size_pack / 1024));
123123
printf("prune-packable: %lu\n", packed_loose);
124124
printf("garbage: %lu\n", garbage);
125125
}
126126
else
127127
printf("%lu objects, %lu kilobytes\n",
128-
loose, loose_size / 1024);
128+
loose, (unsigned long) (loose_size / 1024));
129129
return 0;
130130
}

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,11 +3590,13 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
35903590
if (start_command(&child) != 0 ||
35913591
strbuf_read(&buf, child.out, 0) < 0 ||
35923592
finish_command(&child) != 0) {
3593+
close(child.out);
35933594
strbuf_release(&buf);
35943595
remove_tempfile();
35953596
error("error running textconv command '%s'", pgm);
35963597
return NULL;
35973598
}
3599+
close(child.out);
35983600
remove_tempfile();
35993601

36003602
return strbuf_detach(&buf, outsize);

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

t/t7102-reset.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ test_expect_success \
139139
test_expect_success \
140140
'resetting to HEAD with no changes should succeed and do nothing' '
141141
git reset --hard &&
142-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
142+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
143143
git reset --hard HEAD &&
144-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
144+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
145145
git reset --soft &&
146-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
146+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
147147
git reset --soft HEAD &&
148-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
148+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
149149
git reset --mixed &&
150-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
150+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
151151
git reset --mixed HEAD &&
152-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
152+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
153153
git reset &&
154-
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
154+
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
155155
git reset HEAD &&
156156
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
157157
'

0 commit comments

Comments
 (0)