Skip to content

Commit e5f5219

Browse files
author
Junio C Hamano
committed
GIT 1.0.5
Minor fixes. Starting from this one I won't be touching debian/ directory since the official maintainer seems to be reasonably quick to package up things. The packaging procedure used there seems to be quite different from what I have, so I'd like to avoid potential confusion and reduce work by the official maintainer and myself. Signed-off-by: Junio C Hamano <junkio@cox.net>
2 parents 6ab5889 + 975b31d commit e5f5219

File tree

11 files changed

+137
-23
lines changed

11 files changed

+137
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ all:
5555
# Define USE_STDEV below if you want git to care about the underlying device
5656
# change being considered an inode change from the update-cache perspective.
5757

58-
GIT_VERSION = 1.0.4
58+
GIT_VERSION = 1.0.5
5959

6060
# CFLAGS and LDFLAGS are for the users to override from the command line.
6161

commit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ void sort_in_topological_order(struct commit_list ** list)
560560
next = next->next;
561561
count++;
562562
}
563+
564+
if (!count)
565+
return;
563566
/* allocate an array to help sort the list */
564567
nodes = xcalloc(count, sizeof(*nodes));
565568
/* link the list to the array */

diff.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ static void prepare_temp_file(const char *name,
504504
}
505505
if (S_ISLNK(st.st_mode)) {
506506
int ret;
507-
char *buf, buf_[1024];
508-
buf = ((sizeof(buf_) < st.st_size) ?
509-
xmalloc(st.st_size) : buf_);
507+
char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
508+
if (sizeof(buf) <= st.st_size)
509+
die("symlink too long: %s", name);
510510
ret = readlink(name, buf, st.st_size);
511511
if (ret < 0)
512512
die("readlink(%s)", name);
@@ -650,7 +650,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
650650
if (DIFF_FILE_VALID(one)) {
651651
if (!one->sha1_valid) {
652652
struct stat st;
653-
if (stat(one->path, &st) < 0)
653+
if (lstat(one->path, &st) < 0)
654654
die("stat %s", one->path);
655655
if (index_path(one->sha1, one->path, &st, 0))
656656
die("cannot hash %s\n", one->path);

diffcore-order.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ static int compare_pair_order(const void *a_, const void *b_)
105105
void diffcore_order(const char *orderfile)
106106
{
107107
struct diff_queue_struct *q = &diff_queued_diff;
108-
struct pair_order *o = xmalloc(sizeof(*o) * q->nr);
108+
struct pair_order *o;
109109
int i;
110110

111+
if (!q->nr)
112+
return;
113+
114+
o = xmalloc(sizeof(*o) * q->nr);
111115
prepare_order(orderfile);
112116
for (i = 0; i < q->nr; i++) {
113117
o[i].pair = q->queue[i];

diffcore-pathspec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ void diffcore_pathspec(const char **pathspec)
4848
for (i = 0; pathspec[i]; i++)
4949
;
5050
speccnt = i;
51+
if (!speccnt)
52+
return;
53+
5154
spec = xmalloc(sizeof(*spec) * speccnt);
5255
for (i = 0; pathspec[i]; i++) {
5356
spec[i].spec = pathspec[i];

diffcore-rename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void diffcore_rename(struct diff_options *options)
282282
else if (detect_rename == DIFF_DETECT_COPY)
283283
register_rename_src(p->one, 1);
284284
}
285-
if (rename_dst_nr == 0 ||
285+
if (rename_dst_nr == 0 || rename_src_nr == 0 ||
286286
(0 < rename_limit && rename_limit < rename_dst_nr))
287287
goto cleanup; /* nothing to do */
288288

index-pack.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,18 +352,24 @@ static int sha1_compare(const void *_a, const void *_b)
352352
static void write_index_file(const char *index_name, unsigned char *sha1)
353353
{
354354
struct sha1file *f;
355-
struct object_entry **sorted_by_sha =
356-
xcalloc(nr_objects, sizeof(struct object_entry *));
357-
struct object_entry **list = sorted_by_sha;
358-
struct object_entry **last = sorted_by_sha + nr_objects;
355+
struct object_entry **sorted_by_sha, **list, **last;
359356
unsigned int array[256];
360357
int i;
361358
SHA_CTX ctx;
362359

363-
for (i = 0; i < nr_objects; ++i)
364-
sorted_by_sha[i] = &objects[i];
365-
qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
366-
sha1_compare);
360+
if (nr_objects) {
361+
sorted_by_sha =
362+
xcalloc(nr_objects, sizeof(struct object_entry *));
363+
list = sorted_by_sha;
364+
last = sorted_by_sha + nr_objects;
365+
for (i = 0; i < nr_objects; ++i)
366+
sorted_by_sha[i] = &objects[i];
367+
qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
368+
sha1_compare);
369+
370+
}
371+
else
372+
sorted_by_sha = list = last = NULL;
367373

368374
unlink(index_name);
369375
f = sha1create("%s", index_name);

read-tree.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,20 @@ static int unpack_trees(merge_fn_t fn)
294294
{
295295
int indpos = 0;
296296
unsigned len = object_list_length(trees);
297-
struct tree_entry_list **posns =
298-
xmalloc(len * sizeof(struct tree_entry_list *));
297+
struct tree_entry_list **posns;
299298
int i;
300299
struct object_list *posn = trees;
301300
merge_size = len;
302-
for (i = 0; i < len; i++) {
303-
posns[i] = ((struct tree *) posn->item)->entries;
304-
posn = posn->next;
301+
302+
if (len) {
303+
posns = xmalloc(len * sizeof(struct tree_entry_list *));
304+
for (i = 0; i < len; i++) {
305+
posns[i] = ((struct tree *) posn->item)->entries;
306+
posn = posn->next;
307+
}
308+
if (unpack_trees_rec(posns, len, "", fn, &indpos))
309+
return -1;
305310
}
306-
if (unpack_trees_rec(posns, len, "", fn, &indpos))
307-
return -1;
308311

309312
if (trivial_merges_only && nontrivial_merge)
310313
die("Merge requires file-level merging");

t/t4011-diff-symlink.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2005 Johannes Schindelin
4+
#
5+
6+
test_description='Test diff of symlinks.
7+
8+
'
9+
. ./test-lib.sh
10+
. ../diff-lib.sh
11+
12+
cat > expected << EOF
13+
diff --git a/frotz b/frotz
14+
new file mode 120000
15+
index 0000000..7c465af
16+
--- /dev/null
17+
+++ b/frotz
18+
@@ -0,0 +1 @@
19+
+xyzzy
20+
\ No newline at end of file
21+
EOF
22+
23+
test_expect_success \
24+
'diff new symlink' \
25+
'ln -s xyzzy frotz &&
26+
git-update-index &&
27+
tree=$(git-write-tree) &&
28+
git-update-index --add frotz &&
29+
GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree > current &&
30+
compare_diff_patch current expected'
31+
32+
test_expect_success \
33+
'diff unchanged symlink' \
34+
'tree=$(git-write-tree) &&
35+
git-update-index frotz &&
36+
test -z "$(git-diff-index --name-only $tree)"'
37+
38+
cat > expected << EOF
39+
diff --git a/frotz b/frotz
40+
deleted file mode 120000
41+
index 7c465af..0000000
42+
--- a/frotz
43+
+++ /dev/null
44+
@@ -1 +0,0 @@
45+
-xyzzy
46+
\ No newline at end of file
47+
EOF
48+
49+
test_expect_success \
50+
'diff removed symlink' \
51+
'rm frotz &&
52+
git-diff-index -M -p $tree > current &&
53+
compare_diff_patch current expected'
54+
55+
cat > expected << EOF
56+
diff --git a/frotz b/frotz
57+
EOF
58+
59+
test_expect_success \
60+
'diff identical, but newly created symlink' \
61+
'sleep 1 &&
62+
ln -s xyzzy frotz &&
63+
git-diff-index -M -p $tree > current &&
64+
compare_diff_patch current expected'
65+
66+
cat > expected << EOF
67+
diff --git a/frotz b/frotz
68+
index 7c465af..df1db54 120000
69+
--- a/frotz
70+
+++ b/frotz
71+
@@ -1 +1 @@
72+
-xyzzy
73+
\ No newline at end of file
74+
+yxyyz
75+
\ No newline at end of file
76+
EOF
77+
78+
test_expect_success \
79+
'diff different symlink' \
80+
'rm frotz &&
81+
ln -s yxyyz frotz &&
82+
git-diff-index -M -p $tree > current &&
83+
compare_diff_patch current expected'
84+
85+
test_done

t/t5300-pack-object.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,29 +142,35 @@ test_expect_success \
142142
else :;
143143
fi &&
144144
145+
: PACK_SIGNATURE &&
145146
cp test-1-${packname_1}.pack test-3.pack &&
146147
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
147148
if git-verify-pack test-3.idx
148149
then false
149150
else :;
150151
fi &&
151152
153+
: PACK_VERSION &&
152154
cp test-1-${packname_1}.pack test-3.pack &&
153155
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
154156
if git-verify-pack test-3.idx
155157
then false
156158
else :;
157159
fi &&
158160
161+
: TYPE/SIZE byte of the first packed object data &&
159162
cp test-1-${packname_1}.pack test-3.pack &&
160163
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
161164
if git-verify-pack test-3.idx
162165
then false
163166
else :;
164167
fi &&
165168
169+
: sum of the index file itself &&
170+
l=`wc -c <test-3.idx` &&
171+
l=`expr "$l" - 20` &&
166172
cp test-1-${packname_1}.pack test-3.pack &&
167-
dd if=/dev/zero of=test-3.idx count=1 bs=1 conv=notrunc seek=1200 &&
173+
dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
168174
if git-verify-pack test-3.pack
169175
then false
170176
else :;

0 commit comments

Comments
 (0)