git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSOC 2012] Some questions regarding a possible project to improve big file support

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Mar 26, 2012, 01:21 UTC
Message-ID
<CACsJy8CQHbwCQGypVRgKhD9Wb4O6kXGoDLD9EUZgnBP-6ZivMw@mail.gmail.com>
In-Reply-To
<4F6F8489.20108@gmail.com>
On Mon, Mar 26, 2012 at 3:48 AM, Peter C. <th3flyboy@gmail.com> wrote:
Show 7 quoted lines
> My first question is more of a question regarding low level
> functionality of how Git diffs files. The question is, in the diff
> process, does git just parse the file and see if there are diffs, or
> does it use something like hashing to first tell if the file has been
> modified at all, and then go to the diff process if the hash is
> different. An extension to this question is, in Git's internal database,
> does it set any kind of flag to say that a file is a binary if it is one.

If hashes are available, we compare hash first (e.g. diff-tree). We can mark a file binary with gitattributes. I think the binary detection code, buffer_is_binary, could be just moved up a little bit before we unpack file contents. But I'm not really familiar with this area.

Show 5 quoted lines
> My thought process in implementation involves checking the hash, and if
> the hash is the same, skip it, if the hash is different, check the MIME
> type possibly using libmagic, and if it matches a known binary format,
> then just commit the new version, rather than trying to run a whole diff
> and load the whole file in the process.
Overkill, compared to how binary is detected today :)
#define FIRST_FEW_BYTES 8000
int buffer_is_binary(const char *ptr, unsigned long size)
{
	if (FIRST_FEW_BYTES < size)
		size = FIRST_FEW_BYTES;
	return !!memchr(ptr, 0, size);
}

If you are interested in this big file support, I think you should focus on the "Many large files do not delta well..." item in the wiki page. The framework has already been done by Junio. That can make git manage gigabyte files just fine (aka "bup").

-- 
Duy
Previous: Peter C.
Message 2 of 2 in “[GSOC 2012] Some questions regarding a possible project to improve big file support”
  1. Peter C.Mar 25, 2012
  2. Nguyen Thai Ngoc DuyMar 26, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.