Best way to apply textconv to a working tree file

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Best way to apply textconv to a working tree file

From: Clément Poulain <hidden>
Date: 2016-06-15 22:48:53

Hello,

In order to add textconv support to "git-gui blame", we have to run
textconv on a file which is in the working tree.
Currently, "git-gui blame" uses the Tcl function 'open' to display the
content of the working-tree file. This doesn't allow us to run textconv on
it.

We are wondering what is the best way to do the textconv. Here are some
solutions we thought about:

- For revisions, "git-gui blame" is based on "git cat-file blob
<sha1:path>". Therefore, we thought of adding a "--textconv" option on
cat-file as well as a "--working-tree" option ("git cat-file --working-tree
<file>" will display the content of <file> in the working-tree)

- Use the "-p" (pretty print) cat-file's option, with a path beginning by
./ (to avoid ambiguous name like HEAD)

- Create a "git textconv" command, to easily run textconv on any object.

Which way you think is the best?

Thanks for your time and comments.
Regards

Re: Best way to apply textconv to a working tree file

From: Jeff King <hidden>
Date: 2016-06-15 22:48:53

On Tue, Jun 01, 2010 at 03:41:05PM +0200, Clément Poulain wrote:
We are wondering what is the best way to do the textconv. Here are some
solutions we thought about:
One solution you didn't mention would be to do it all yourself:

  driver=`git check-attr diff "$file" | cut -d: -f3`
  textconv=`git config diff.$driver.textconv`
  $textconv <$file >$file.converted

This has the advantage of working with existing versions of git. The
downside is that it's more code (e.g., my parsing above is quite sloppy
and loose. Doing it right would be a few more lines).

Furthermore, it doesn't use the textconv cache at all. For working tree
files, this might not matter (if you pull the sha1 out of the index,
though, you can still check the cache, and unchanged working tree files
are likely to be in the cache). But for blobs in general, the cache is
worth using.

-Peff

Re: Best way to apply textconv to a working tree file

From: Clément Poulain <hidden>
Date: 2016-06-15 22:48:54

On Tue, 1 Jun 2010 13:04:27 -0400, Jeff King [off-list ref] wrote:
On Tue, Jun 01, 2010 at 03:41:05PM +0200, Clément Poulain wrote:
quoted
We are wondering what is the best way to do the textconv. Here are some
solutions we thought about:
One solution you didn't mention would be to do it all yourself:

  driver=`git check-attr diff "$file" | cut -d: -f3`
  textconv=`git config diff.$driver.textconv`
  $textconv <$file >$file.converted

This has the advantage of working with existing versions of git. The
downside is that it's more code (e.g., my parsing above is quite sloppy
and loose. Doing it right would be a few more lines).

Furthermore, it doesn't use the textconv cache at all. For working tree
files, this might not matter (if you pull the sha1 out of the index,
though, you can still check the cache, and unchanged working tree files
are likely to be in the cache). But for blobs in general, the cache is
worth using.

-Peff
It seems to really fit for git gui. 
About the cache : this method will be only used by git gui (when it's
launched) on working tree files, so it seems OK for me.
Thank you
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help