Skip to content

Commit dd1cec5

Browse files
committed
Merge branch 'jk/remove-experimental-loose-object-support'
* jk/remove-experimental-loose-object-support: drop support for "experimental" loose objects
2 parents e2bcd4f + b039718 commit dd1cec5

19 files changed

+0
-143
lines changed

sha1_file.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,51 +1442,6 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
14421442
return map;
14431443
}
14441444

1445-
/*
1446-
* There used to be a second loose object header format which
1447-
* was meant to mimic the in-pack format, allowing for direct
1448-
* copy of the object data. This format turned up not to be
1449-
* really worth it and we no longer write loose objects in that
1450-
* format.
1451-
*/
1452-
static int experimental_loose_object(unsigned char *map)
1453-
{
1454-
unsigned int word;
1455-
1456-
/*
1457-
* We must determine if the buffer contains the standard
1458-
* zlib-deflated stream or the experimental format based
1459-
* on the in-pack object format. Compare the header byte
1460-
* for each format:
1461-
*
1462-
* RFC1950 zlib w/ deflate : 0www1000 : 0 <= www <= 7
1463-
* Experimental pack-based : Stttssss : ttt = 1,2,3,4
1464-
*
1465-
* If bit 7 is clear and bits 0-3 equal 8, the buffer MUST be
1466-
* in standard loose-object format, UNLESS it is a Git-pack
1467-
* format object *exactly* 8 bytes in size when inflated.
1468-
*
1469-
* However, RFC1950 also specifies that the 1st 16-bit word
1470-
* must be divisible by 31 - this checksum tells us our buffer
1471-
* is in the standard format, giving a false positive only if
1472-
* the 1st word of the Git-pack format object happens to be
1473-
* divisible by 31, ie:
1474-
* ((byte0 * 256) + byte1) % 31 = 0
1475-
* => 0ttt10000www1000 % 31 = 0
1476-
*
1477-
* As it happens, this case can only arise for www=3 & ttt=1
1478-
* - ie, a Commit object, which would have to be 8 bytes in
1479-
* size. As no Commit can be that small, we find that the
1480-
* combination of these two criteria (bitmask & checksum)
1481-
* can always correctly determine the buffer format.
1482-
*/
1483-
word = (map[0] << 8) + map[1];
1484-
if ((map[0] & 0x8F) == 0x08 && !(word % 31))
1485-
return 0;
1486-
else
1487-
return 1;
1488-
}
1489-
14901445
unsigned long unpack_object_header_buffer(const unsigned char *buf,
14911446
unsigned long len, enum object_type *type, unsigned long *sizep)
14921447
{
@@ -1514,42 +1469,13 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
15141469

15151470
int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz)
15161471
{
1517-
unsigned long size, used;
1518-
static const char valid_loose_object_type[8] = {
1519-
0, /* OBJ_EXT */
1520-
1, 1, 1, 1, /* "commit", "tree", "blob", "tag" */
1521-
0, /* "delta" and others are invalid in a loose object */
1522-
};
1523-
enum object_type type;
1524-
15251472
/* Get the data stream */
15261473
memset(stream, 0, sizeof(*stream));
15271474
stream->next_in = map;
15281475
stream->avail_in = mapsize;
15291476
stream->next_out = buffer;
15301477
stream->avail_out = bufsiz;
15311478

1532-
if (experimental_loose_object(map)) {
1533-
/*
1534-
* The old experimental format we no longer produce;
1535-
* we can still read it.
1536-
*/
1537-
used = unpack_object_header_buffer(map, mapsize, &type, &size);
1538-
if (!used || !valid_loose_object_type[type])
1539-
return -1;
1540-
map += used;
1541-
mapsize -= used;
1542-
1543-
/* Set up the stream for the rest.. */
1544-
stream->next_in = map;
1545-
stream->avail_in = mapsize;
1546-
git_inflate_init(stream);
1547-
1548-
/* And generate the fake traditional header */
1549-
stream->total_out = 1 + snprintf(buffer, bufsiz, "%s %lu",
1550-
typename(type), size);
1551-
return 0;
1552-
}
15531479
git_inflate_init(stream);
15541480
return git_inflate(stream, 0);
15551481
}

t/t1013-loose-object-format.sh

Lines changed: 0 additions & 66 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

t/t1013/objects/76/e7fa9941f4d5f97f64fea65a2cba436bc79cbb

Lines changed: 0 additions & 2 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

t/t1013/objects/f8/16d5255855ac160652ee5253b06cd8ee14165a

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)