Skip to content

Commit 01df529

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
Handling large files with GIT
On Tue, 14 Feb 2006, Linus Torvalds wrote: > > Here, btw, is the trivial diff to turn my previous "tree-resolve" into a > "resolve tree relative to the current branch". Gaah. It was trivial, and it happened to work fine for my test-case, but when I started looking at not doing that extremely aggressive subdirectory merging, that showed a few other issues... So in case people want to try, here's a third patch. Oh, and it's against my _original_ path, not incremental to the middle one (ie both patches two and three are against patch #1, it's not a nice series). Now I'm really done, and won't be sending out any more patches today. Sorry for the noise. Linus Signed-off-by: Junio C Hamano <[email protected]>
1 parent 492e075 commit 01df529

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

merge-tree.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,26 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
5555
a->mode == b->mode;
5656
}
5757

58-
static void resolve(const char *base, struct name_entry *result)
58+
static const char *sha1_to_hex_zero(const unsigned char *sha1)
5959
{
60-
printf("0 %06o %s %s%s\n", result->mode, sha1_to_hex(result->sha1), base, result->path);
60+
if (sha1)
61+
return sha1_to_hex(sha1);
62+
return "0000000000000000000000000000000000000000";
63+
}
64+
65+
static void resolve(const char *base, struct name_entry *branch1, struct name_entry *result)
66+
{
67+
char branch1_sha1[50];
68+
69+
/* If it's already branch1, don't bother showing it */
70+
if (!branch1)
71+
return;
72+
memcpy(branch1_sha1, sha1_to_hex_zero(branch1->sha1), 41);
73+
74+
printf("0 %06o->%06o %s->%s %s%s\n",
75+
branch1->mode, result->mode,
76+
branch1_sha1, sha1_to_hex_zero(result->sha1),
77+
base, result->path);
6178
}
6279

6380
static int unresolved_directory(const char *base, struct name_entry n[3])
@@ -100,9 +117,12 @@ static void unresolved(const char *base, struct name_entry n[3])
100117
{
101118
if (unresolved_directory(base, n))
102119
return;
103-
printf("1 %06o %s %s%s\n", n[0].mode, sha1_to_hex(n[0].sha1), base, n[0].path);
104-
printf("2 %06o %s %s%s\n", n[1].mode, sha1_to_hex(n[1].sha1), base, n[1].path);
105-
printf("3 %06o %s %s%s\n", n[2].mode, sha1_to_hex(n[2].sha1), base, n[2].path);
120+
if (n[0].sha1)
121+
printf("1 %06o %s %s%s\n", n[0].mode, sha1_to_hex(n[0].sha1), base, n[0].path);
122+
if (n[1].sha1)
123+
printf("2 %06o %s %s%s\n", n[1].mode, sha1_to_hex(n[1].sha1), base, n[1].path);
124+
if (n[2].sha1)
125+
printf("3 %06o %s %s%s\n", n[2].mode, sha1_to_hex(n[2].sha1), base, n[2].path);
106126
}
107127

108128
/*
@@ -183,21 +203,21 @@ static void merge_trees(struct tree_desc t[3], const char *base)
183203
/* Same in both? */
184204
if (same_entry(entry+1, entry+2)) {
185205
if (entry[0].sha1) {
186-
resolve(base, entry+1);
206+
resolve(base, NULL, entry+1);
187207
continue;
188208
}
189209
}
190210

191211
if (same_entry(entry+0, entry+1)) {
192-
if (entry[2].sha1) {
193-
resolve(base, entry+2);
212+
if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
213+
resolve(base, entry+1, entry+2);
194214
continue;
195215
}
196216
}
197217

198218
if (same_entry(entry+0, entry+2)) {
199-
if (entry[1].sha1) {
200-
resolve(base, entry+1);
219+
if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
220+
resolve(base, NULL, entry+1);
201221
continue;
202222
}
203223
}

0 commit comments

Comments
 (0)