<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/git.git/convert.c, branch v1.5.4.4</title>
<subtitle>Git
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.5.4.4</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.5.4.4'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/'/>
<updated>2008-02-11T21:11:36Z</updated>
<entry>
<title>convert.c: guard config parser from value=NULL</title>
<updated>2008-02-11T21:11:36Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2008-02-11T18:53:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=a7269e5cb703083efb084ba19bc703ebc915aa5c'/>
<id>urn:sha1:a7269e5cb703083efb084ba19bc703ebc915aa5c</id>
<content type='text'>
filter.*.smudge and filter.*.clean configuration variables expect a
string value.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>treat any file with NUL as binary</title>
<updated>2008-01-16T17:10:34Z</updated>
<author>
<name>Dmitry Potapov</name>
<email>dpotapov@gmail.com</email>
</author>
<published>2008-01-16T01:59:12Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=28624193b2ce622144136d373e136455b6b13967'/>
<id>urn:sha1:28624193b2ce622144136d373e136455b6b13967</id>
<content type='text'>
There are two heuristics in Git to detect whether a file is binary
or text. One in xdiff-interface.c (which is taken from GNU diff)
relies on existence of the NUL byte at the beginning. However,
convert.c used a different heuristic, which relied on the percent
of non-printable symbols (less than 1% for text files).

Due to differences in detection whether a file is binary or not,
it was possible that a file that diff treats as binary could be
treated as text by CRLF conversion. This is very confusing for a
user who sees that 'git diff' shows the file as binary expects it
to be added as binary.

This patch makes is_binary to consider any file that contains at
least one NUL character as binary, to ensure that the heuristics
used for CRLF conversion is tighter than what is used by diff.

Signed-off-by: Dmitry Potapov &lt;dpotapov@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Use the asyncronous function infrastructure to run the content filter.</title>
<updated>2007-10-21T05:30:42Z</updated>
<author>
<name>Johannes Sixt</name>
<email>johannes.sixt@telecom.at</email>
</author>
<published>2007-10-19T19:48:06Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=546bb5823249678bc6ad11e65661d896ed83448a'/>
<id>urn:sha1:546bb5823249678bc6ad11e65661d896ed83448a</id>
<content type='text'>
Signed-off-by: Johannes Sixt &lt;johannes.sixt@telecom.at&gt;
Signed-off-by: Shawn O. Pearce &lt;spearce@spearce.org&gt;
</content>
</entry>
<entry>
<title>Avoid a dup2(2) in apply_filter() - start_command() can do it for us.</title>
<updated>2007-10-21T05:30:42Z</updated>
<author>
<name>Johannes Sixt</name>
<email>johannes.sixt@telecom.at</email>
</author>
<published>2007-10-19T19:48:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=7683b6e81fa0f1f55d4974d69fb87c7c7b6b394e'/>
<id>urn:sha1:7683b6e81fa0f1f55d4974d69fb87c7c7b6b394e</id>
<content type='text'>
When apply_filter() runs the external (clean or smudge) filter program, it
needs to pass the writable end of a pipe as its stdout. For this purpose,
it used to dup2(2) the file descriptor explicitly to stdout. Now we use
the facilities of start_command() to do it for us.

Furthermore, the path argument of a subordinate function, filter_buffer(),
was not used, so here we replace it to pass the fd instead.

Signed-off-by: Johannes Sixt &lt;johannes.sixt@telecom.at&gt;
Signed-off-by: Shawn O. Pearce &lt;spearce@spearce.org&gt;
</content>
</entry>
<entry>
<title>Use start_command() to run content filters instead of explicit fork/exec.</title>
<updated>2007-10-21T05:30:39Z</updated>
<author>
<name>Johannes Sixt</name>
<email>johannes.sixt@telecom.at</email>
</author>
<published>2007-10-19T19:47:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=dc1bfdcd1a8af81885f1831c5e6dcfe5cf61372e'/>
<id>urn:sha1:dc1bfdcd1a8af81885f1831c5e6dcfe5cf61372e</id>
<content type='text'>
The previous code already used finish_command() to wait for the process
to terminate, but did not use start_command() to run it.

Signed-off-by: Johannes Sixt &lt;johannes.sixt@telecom.at&gt;
Signed-off-by: Shawn O. Pearce &lt;spearce@spearce.org&gt;
</content>
</entry>
<entry>
<title>Fix in-place editing functions in convert.c</title>
<updated>2007-10-16T01:38:09Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-10-05T08:11:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=90d16ec032b20f9f1146f3aceca12165aba3b6d6'/>
<id>urn:sha1:90d16ec032b20f9f1146f3aceca12165aba3b6d6</id>
<content type='text'>
* crlf_to_git and ident_to_git:

  Don't grow the buffer if there is enough space in the first place.
  As a side effect, when the editing is done "in place", we don't grow, so
  the buffer pointer doesn't changes, and `src' isn't invalidated anymore.

  Thanks to Bernt Hansen for the bug report.

* apply_filter:

  Fix memory leak due to fake in-place editing that didn't collected the
  old buffer when the filter succeeds. Also a cosmetic fix.

Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Signed-off-by: Lars Hjemli &lt;hjemli@gmail.com&gt;
Signed-off-by: Shawn O. Pearce &lt;spearce@spearce.org&gt;
</content>
</entry>
<entry>
<title>strbuf change: be sure -&gt;buf is never ever NULL.</title>
<updated>2007-09-29T09:13:33Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-09-27T10:58:23Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=b315c5c08139c0d3c1e4867a305334e29da01d07'/>
<id>urn:sha1:b315c5c08139c0d3c1e4867a305334e29da01d07</id>
<content type='text'>
For that purpose, the -&gt;buf is always initialized with a char * buf living
in the strbuf module. It is made a char * so that we can sloppily accept
things that perform: sb-&gt;buf[0] = '\0', and because you can't pass "" as an
initializer for -&gt;buf without making gcc unhappy for very good reasons.

strbuf_init/_detach/_grow have been fixed to trust -&gt;alloc and not -&gt;buf
anymore.

as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
-&gt;buf isn't an option anymore, if -&gt;buf is going to escape from the scope,
and eventually be free'd.

API changes:
  * strbuf_setlen now always works, so just make strbuf_reset a convenience
    macro.
  * strbuf_detatch takes a size_t* optional argument (meaning it can be
    NULL) to copy the buffer's len, as it was needed for this refactor to
    make the code more readable, and working like the callers.

Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Use xmemdupz() in many places.</title>
<updated>2007-09-19T00:42:17Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-09-15T22:32:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=182af8343c307436bb5364309aa6d4d46fa5911d'/>
<id>urn:sha1:182af8343c307436bb5364309aa6d4d46fa5911d</id>
<content type='text'>
Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Now that cache.h needs strbuf.h, remove useless includes.</title>
<updated>2007-09-17T00:30:03Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-09-15T13:56:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=ba3ed09728cb25e004d3b732de14fca8aeb602f6'/>
<id>urn:sha1:ba3ed09728cb25e004d3b732de14fca8aeb602f6</id>
<content type='text'>
Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Rewrite convert_to_{git,working_tree} to use strbuf's.</title>
<updated>2007-09-17T00:30:03Z</updated>
<author>
<name>Pierre Habouzit</name>
<email>madcoder@debian.org</email>
</author>
<published>2007-09-16T13:51:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=5ecd293d1420bf641a927a015877950f4d79c067'/>
<id>urn:sha1:5ecd293d1420bf641a927a015877950f4d79c067</id>
<content type='text'>
* Now, those functions take an "out" strbuf argument, where they store their
  result if any. In that case, it also returns 1, else it returns 0.
* those functions support "in place" editing, in the sense that it's OK to
  call them this way:
    convert_to_git(path, sb-&gt;buf, sb-&gt;len, sb);
  When doable, conversions are done in place for real, else the strbuf
  content is just replaced with the new one, transparentely for the caller.

If you want to create a new filter working this way, being the accumulation
of filter1, filter2, ... filtern, then your meta_filter would be:

    int meta_filter(..., const char *src, size_t len, struct strbuf *sb)
    {
        int ret = 0;
        ret |= filter1(...., src, len, sb);
        if (ret) {
            src = sb-&gt;buf;
            len = sb-&gt;len;
        }
        ret |= filter2(...., src, len, sb);
        if (ret) {
            src = sb-&gt;buf;
            len = sb-&gt;len;
        }
        ....
        return ret | filtern(..., src, len, sb);
    }

That's why subfilters the convert_to_* functions called were also rewritten
to work this way.

Signed-off-by: Pierre Habouzit &lt;madcoder@debian.org&gt;
Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
