{"thread":{"id":"14615","subject":"git-svn does not seems to work with crlf convertion enabled.","startedAt":"2008-07-23T08:44:23Z","lastAt":"2008-08-06T16:11:25Z","messageCount":45,"participants":["Alexander Litvinov","Johannes Schindelin","Avery Pennarun","Dmitry Potapov","Junio C Hamano","Eric Wong","Petr Baudis","Peter Harris"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84447","messageId":"200807231544.23472.litvinov2004@gmail.com","threadId":"14615","inReplyTo":null,"subject":"git-svn does not seems to work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-23T08:44:23Z","receivedAt":"2008-07-23T08:44:23Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"Hello list.\n\nIn short: I can't clone svn repo into git when crlf convertion is activated.\n\nLong story.\nI use latest git: \n$ git version\ngit version 1.5.6.4\n\nFor a long period of time I use git at work. Main repo is svn-powered and I \nuse git-svn for linking git and svn. The project itself is a windows cpp \nproject. I use git under Linux machine (Debian etch with manually backported \ngit from sid) and work with linux-hosted project thru samba. From the begin I \ndid not enable crlf convertion and broke crlf notation in files one by one \nduring my commits. My co-workers does not like this and finally I decide to \ntry to use autocrlf feature of git. So I take a copy of my git repo and \nconvert all text files to unix LF line endings:\n\ngit filter-branch --tree-filter \"find -type f \\( -iname '*.h' -or \\\n-iname '*.cpp' -or -iname '*.vcproj' -or -iname '*.sln' -or \\\n-iname '*.h.tmpl' -or -iname '*.bat' -or -iname '*.mp' -or \\\n-iname '*.txt' -or -iname '*.nsi' -or -iname '*.def' -or \\\n-iname '*.rc' -or -iname '*.ini' -or -iname '*.inf' -or \\\n-iname '*.skin' -or -iname '*.c' -or -iname '*.dsp' \\\n-or -iname '*.dsw' \\) -print0 | xargs -r0 dos2unix\" \\\n`git branch -a | sed 's/^..//'`\n\nIt finished succefully. After fish I have added  .git/info/attributes like \nthis:\n*               -crlf\n*.h             crlf\n*.c             crlf\n*.cpp           crlf\nand so on...\nand add set core.autocrlf to true and safecrlf to false. Also I cleared all \ngit-svn's caches:\nrm -rf .git/svn\n\nAs I understand I got pure repo that is capable to work with crlf convertion. \nLets update it (on branch forked from trunk): git svn rebase\n<.. some long list of revs during migration to new git-svn layout..>\nDone rebuilding .git/svn/trunk/.rev_map.f1f59411-8b2e-0410-9ee3-aa470c928bf2\n        M       FindHistory.cpp\nIncomplete data: Delta source ended unexpectedly at /tmp/g/bin/git-svn line \n3856\n\nOops ! Whats this ? I am not able to update. I can update other branches but \nnot trunk.\n\nSo I have to try my old original repo without crlf convertion enabled. It was \nupdated succeffuly, I cant show log it was lost and I was not able to \nreproduce it.\n\n\n\nIs there any way to fix this problem ?\n\nP.S. I can't even clone that svn repo from scratch with crlf convertion \nenabled.\n"},{"id":"84452","messageId":"alpine.DEB.1.00.0807231117290.2830@eeepc-johanness","threadId":"14615","inReplyTo":"200807231544.23472.litvinov2004@gmail.com","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-23T09:18:12Z","receivedAt":"2008-07-23T09:18:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Alexander Litvinov wrote:\n\n> In short: I can't clone svn repo into git when crlf convertion is \n> activated.\n\nThis is a known issue, but since nobody with that itch seems to care \nenough to fix it, I doubt it will ever be fixed.\n\nCiao,\nDscho\n"},{"id":"84473","messageId":"200807231852.10206.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231117290.2830@eeepc-johanness","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-23T11:52:09Z","receivedAt":"2008-07-23T11:52:09Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> > In short: I can't clone svn repo into git when crlf convertion is\n> > activated.\n>\n> This is a known issue, but since nobody with that itch seems to care\n> enough to fix it, I doubt it will ever be fixed.\n\nThat is a bad news for me. Anyway I will spend some time at holidays during \ndigging this bug. \n"},{"id":"84479","messageId":"alpine.DEB.1.00.0807231356540.8986@racer","threadId":"14615","inReplyTo":"200807231852.10206.litvinov2004@gmail.com","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-23T12:57:54Z","receivedAt":"2008-07-23T12:57:54Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Alexander Litvinov wrote:\n\n> > On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> > > In short: I can't clone svn repo into git when crlf convertion is \n> > > activated.\n> >\n> > This is a known issue, but since nobody with that itch seems to care \n> > enough to fix it, I doubt it will ever be fixed.\n> \n> That is a bad news for me. Anyway I will spend some time at holidays \n> during digging this bug.\n\nNote that you will have to do your digging using msysGit (i.e. the \ndeveloper's pack, not the installer for plain Git), since git-svn will be \nremoved from the next official \"Windows Git\" release, due to lack of \nfixers.\n\nCiao,\nDscho\n"},{"id":"84525","messageId":"32541b130807230849t42b491b9jf1d6f31bcdd50dac@mail.gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231356540.8986@racer","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-23T15:49:04Z","receivedAt":"2008-07-23T15:49:04Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/23/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>  On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n>  > > On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n>  > > > In short: I can't clone svn repo into git when crlf convertion is\n>  > > > activated.\n>  > >\n>  > > This is a known issue, but since nobody with that itch seems to care\n>  > > enough to fix it, I doubt it will ever be fixed.\n>  >\n>  > That is a bad news for me. Anyway I will spend some time at holidays\n>  > during digging this bug.\n>\n> Note that you will have to do your digging using msysGit (i.e. the\n>  developer's pack, not the installer for plain Git), since git-svn will be\n>  removed from the next official \"Windows Git\" release, due to lack of\n>  fixers.\n\nPresumably cygwin git will work too, right?\n\nDoes this known issue apply only to msysGit, or both msys and Cygwin,\nor all versions?  ie. could it be debugged on Linux?\n\nThanks,\n\nAvery\n"},{"id":"84532","messageId":"alpine.DEB.1.00.0807231706520.8986@racer","threadId":"14615","inReplyTo":"32541b130807230849t42b491b9jf1d6f31bcdd50dac@mail.gmail.com","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-23T16:07:31Z","receivedAt":"2008-07-23T16:07:31Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Avery Pennarun wrote:\n\n> On 7/23/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> >  On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> >  > > On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> >  > > > In short: I can't clone svn repo into git when crlf convertion \n> >  > > > is activated.\n> >  > >\n> >  > > This is a known issue, but since nobody with that itch seems to \n> >  > > care enough to fix it, I doubt it will ever be fixed.\n> >  >\n> >  > That is a bad news for me. Anyway I will spend some time at \n> >  > holidays during digging this bug.\n> >\n> > Note that you will have to do your digging using msysGit (i.e. the \n> > developer's pack, not the installer for plain Git), since git-svn will \n> > be removed from the next official \"Windows Git\" release, due to lack \n> > of fixers.\n> \n> Presumably cygwin git will work too, right?\n\nYes.\n\n> Does this known issue apply only to msysGit, or both msys and Cygwin, or \n> all versions?  ie. could it be debugged on Linux?\n\nYou mean the crlf vs git-svn issue?  No, yes, yes, yes, and yes.\n\nCiao,\nDscho\n"},{"id":"84666","messageId":"200807241013.00862.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231356540.8986@racer","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-24T03:13:00Z","receivedAt":"2008-07-24T03:13:00Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> Note that you will have to do your digging using msysGit (i.e. the\n> developer's pack, not the installer for plain Git), since git-svn will be\n> removed from the next official \"Windows Git\" release, due to lack of\n> fixers.\n\nYou will not believe me. I use git under Linux, develop under windows on \nnetwork drive :-)\n"},{"id":"84721","messageId":"20080724142453.GV2925@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"200807231852.10206.litvinov2004@gmail.com","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-07-24T14:24:53Z","receivedAt":"2008-07-24T14:24:53Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Wed, Jul 23, 2008 at 06:52:09PM +0700, Alexander Litvinov wrote:\n> > On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> > > In short: I can't clone svn repo into git when crlf convertion is\n> > > activated.\n> >\n> > This is a known issue, but since nobody with that itch seems to care\n> > enough to fix it, I doubt it will ever be fixed.\n> \n> That is a bad news for me. Anyway I will spend some time at holidays during \n> digging this bug. \n\nI don't want to discourage from digging into this problem, but there are\ntwo reasons why no one has fixed this issue yet. First, configuration\nCRLF conversion in Git and SVN is quite different, so it may not be easy\nto have the solution that will work in all cases. Second, in many cases,\nyou can workaround this issue.\n\nIf I understood your situation correctly, you use SVN repo where text\nfiles are marked with svn:eol-style=native. In this case, SVN stores\nthese files with LF endings internally, and git-svn receives files in\nthat format (at least, it is so on Debian).  Practically all Windows\neditors do not have problems to open and edit files with LF endings, but\nsome of them will write back using CRLF. You do not want CRLF to get in\nyour Git repository, so you can do that by setting core.autocrlf=input.\nThis might work for you...\n\nDmitry\n"},{"id":"84723","messageId":"alpine.DEB.1.00.0807241539400.8986@racer","threadId":"14615","inReplyTo":"20080724142453.GV2925@dpotapov.dyndns.org","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-24T14:40:59Z","receivedAt":"2008-07-24T14:40:59Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 24 Jul 2008, Dmitry Potapov wrote:\n\n> On Wed, Jul 23, 2008 at 06:52:09PM +0700, Alexander Litvinov wrote:\n> > > On Wed, 23 Jul 2008, Alexander Litvinov wrote:\n> > > > In short: I can't clone svn repo into git when crlf convertion is \n> > > > activated.\n> > >\n> > > This is a known issue, but since nobody with that itch seems to care \n> > > enough to fix it, I doubt it will ever be fixed.\n> > \n> > That is a bad news for me. Anyway I will spend some time at holidays \n> > during digging this bug.\n> \n> I don't want to discourage from digging into this problem\n\nGreat.  Thanks.  There is someone who is actually willing to work on the \nproblem.\n\n> Practically all Windows editors do not have problems to open and edit \n> files with LF endings, but some of them will write back using CRLF.\n\n95.23% of all statistics are made up on the spot.  I would be surprised if \nthat was not the case here.\n\nCiao,\nDscho\n"},{"id":"84736","messageId":"32541b130807240928u695277bfx4873a3f782e3abc@mail.gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807241539400.8986@racer","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-24T16:28:00Z","receivedAt":"2008-07-24T16:28:00Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/24/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>  On Thu, 24 Jul 2008, Dmitry Potapov wrote:\n>  > Practically all Windows editors do not have problems to open and edit\n>  > files with LF endings, but some of them will write back using CRLF.\n>\n> 95.23% of all statistics are made up on the spot.  I would be surprised if\n>  that was not the case here.\n\nWithout assigning a specific number, Dmitry's experience matches mine.\n I haven't seen an editor that can't *read* LF since notepad.  But\nmany of them happily mangle the files.\n\nOf course, notepad is probably at least 50% of the editors most\nWindows users actually use, on a per-transaction basis.\n\nHave fun,\n\nAvery\n"},{"id":"85567","messageId":"200807301137.04669.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231117290.2830@eeepc-johanness","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-30T04:37:04Z","receivedAt":"2008-07-30T04:37:04Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> This is a known issue, but since nobody with that itch seems to care\n> enough to fix it, I doubt it will ever be fixed.\n\nHello again.\n\nI have investigated this problem. Short result: git-svn and ANY file \nconvertion will not work now.\n\nIn my case I have found the problem is the \nSVN::Git::Fetcher::apply_textdelta() function. To be more precicly call to \nSVN::TxDelta::apply(). We fetch previous version of file from git and then \napply to it svn's delta. As far as we modify src file SVN fails to apply its \ndelta. If I modify last commit and put original version of file everything \nworks.\n\nSo it seems to me there are two solutions: \n1. Store original file somehow and use it to construct new file version;\n2. In case of this error we could fetch full blob with new (or old) version of \nthe file.\n\nI did not find the way to gather full file conntent nor feel myself ready to \nrewrite git-svn to store original file somewhere.\n\nDoes anybody can help or comment on this ?\n"},{"id":"85724","messageId":"200807311243.35219.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231117290.2830@eeepc-johanness","subject":"[PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-31T05:43:34Z","receivedAt":"2008-07-31T05:43:34Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"Make git-svn works with crlf (or any other) file content convertion enabled.\n\nWhen we modify file content SVN cant apply its delta to it. To fix this\nsituation I take full file content from SVN as next revision. This is\ndump and slow but it works.\n---\n git-svn.perl |   34 +++++++++++++++++++---------------\n 1 files changed, 19 insertions(+), 15 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex cf6dbbc..606a177 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -28,6 +28,7 @@ sub fatal (@) { print STDERR \"@_\\n\"; exit 1 }\n require SVN::Core; # use()-ing this causes segfaults for me... *shrug*\n require SVN::Ra;\n require SVN::Delta;\n+require SVN::Client;\n if ($SVN::Core::VERSION lt '1.1.0') {\n \tfatal \"Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)\";\n }\n@@ -3075,6 +3076,7 @@ sub new {\n \tmy $self = SVN::Delta::Editor->new;\n \tbless $self, $class;\n \t$self->{c} = $git_svn->{last_commit} if exists $git_svn->{last_commit};\n+\t$self->{url} = $git_svn->{url};\n \t$self->{empty} = {};\n \t$self->{dir_prop} = {};\n \t$self->{file_prop} = {};\n@@ -3214,30 +3216,32 @@ sub change_file_prop {\n \n sub apply_textdelta {\n \tmy ($self, $fb, $exp) = @_;\n-\tmy $fh = IO::File->new_tmpfile;\n-\t$fh->autoflush(1);\n-\t# $fh gets auto-closed() by SVN::TxDelta::apply(),\n-\t# (but $base does not,) so dup() it for reading in close_file\n-\topen my $dup, '<&', $fh or croak $!;\n+\n \tmy $base = IO::File->new_tmpfile;\n \t$base->autoflush(1);\n \tif ($fb->{blob}) {\n \t\tprint $base 'link ' if ($fb->{mode_a} == 120000);\n \t\tmy $size = $::_repository->cat_blob($fb->{blob}, $base);\n \t\tdie \"Failed to read object $fb->{blob}\" if ($size < 0);\n-\n-\t\tif (defined $exp) {\n-\t\t\tseek $base, 0, 0 or croak $!;\n-\t\t\tmy $got = ::md5sum($base);\n-\t\t\tdie \"Checksum mismatch: $fb->{path} $fb->{blob}\\n\",\n-\t\t\t    \"expected: $exp\\n\",\n-\t\t\t    \"     got: $got\\n\" if ($got ne $exp);\n-\t\t}\n \t}\n \tseek $base, 0, 0 or croak $!;\n-\t$fb->{fh} = $dup;\n+\n+\tmy $fh = IO::File->new_tmpfile;\n+\t$fh->autoflush(1);\n+\n+\t$fb->{fh} = $fh;\n \t$fb->{base} = $base;\n-\t[ SVN::TxDelta::apply($base, $fh, undef, $fb->{path}, $fb->{pool}) ];\n+\n+\tmy $url = $self->{url};\n+\t$url =~ s/\\/$//;\n+\t$url .= '/';\n+\t$url .= $fb->{path};\n+\n+\tmy $rev = $self->{file_prop}->{$fb->{path}}->{'svn:entry:committed-rev'};\n+\tdie (\"Can't find $fb->{path} revision\") unless defined $rev;\n+\n+\tmy $ctx = SVN::Client->new();\n+\t$ctx->cat($fh, $url, $rev);\n }\n \n sub close_file {\n-- \n1.5.6.2\n"},{"id":"85727","messageId":"200807311257.49108.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"200807311243.35219.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-07-31T05:57:48Z","receivedAt":"2008-07-31T05:57:48Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> Make git-svn works with crlf (or any other) file content convertion\n> enabled.\n>\n> When we modify file content SVN cant apply its delta to it. To fix this\n> situation I take full file content from SVN as next revision. This is\n> dump and slow but it works.\n\nSorry for the noise. \n\ngit-svn fetch files with this patch but I have found that git-svn use \ngit-hash-object and provide file name to store into stdin. As far as file is \na temp file git-hash-object can't correctly apply crlf convertion for the \nfile.\n\nAs a conclusion: git-svn does not apply crlf convertion on files being stored \ninto git repo. This make my patch useless.\n"},{"id":"85755","messageId":"20080731104529.GE7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"200807311257.49108.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-07-31T10:45:29Z","receivedAt":"2008-07-31T10:45:29Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Thu, Jul 31, 2008 at 12:57:48PM +0700, Alexander Litvinov wrote:\n> \n> git-svn fetch files with this patch but I have found that git-svn use \n> git-hash-object and provide file name to store into stdin. As far as file is \n> a temp file git-hash-object can't correctly apply crlf convertion for the \n> file.\n\nIt does not look to be true. I did the following test:\n\nmkdir hash_test\ncd hash_test\ngit init\n\ncat <<\\=== > hash_test.pl\n#!/usr/bin/env perl\n\nuse File::Temp qw/tempfile/;\n\nmy ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1);\nprint $tmp_fh \"Hi\\r\\n\";\n$tmp_fh->flush;\nsystem (\"echo $tmp_filename | git hash-object --stdin-paths\");\n===\n\ngit config core.autocrlf true\nperl hash_test.pl\ngit config core.autocrlf false\nperl hash_test.pl\n\n\nand the output was\nb14df6442ea5a1b382985a6549b85d435376c351\nea6b6afbc2cbed0eb8c0f7561286ab72f349416c\n\nwhich means that the autocrlf conversion is done for temporary\nfiles created by perl. (I tested it on Linux and Windows/Cygwin).\n\nIn any case, I believe the right solution should be adding a\nnew option to git-hash-object to disable any conversion.\n\nDmitry\n"},{"id":"85801","messageId":"20080731190949.GI7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"20080731104529.GE7008@dpotapov.dyndns.org","subject":"[RFC] hash-object --no-filters","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-07-31T19:09:49Z","receivedAt":"2008-07-31T19:09:49Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"Hi All,\n\nI am tryint to add the --no-filters option. It is useful for git-svn\nand other importers that want to add file as-is without being affected\nby any filter (in particular, autocrlf). Though, the patch below works,\nI am not happy with the hackish way of passing no-filter requirement\nto the index_fd() function. So, I wonder what would be preferable:\n- to change 'write_object' to be flags (bit 0: write_object,\n  bit 1: no-filters )\n- to add some global the no_filters flag to environment.c, which can\n  be checked inside of convert_to_git(), so it may be used in the\n  future in some other cases (though I don't see where else it can\n  be useful).\n\nAnother question: currently git hash-object --input imply no filters.\nI don't know if it was done intentionally (it can be argued in both\nways). I don't think it is reasonable now to change this behavior,\nso I want to add just one line to documentation, so there will be\nno surprise among users.\n\nDmitry\n\n-- 8< --\nFrom: Dmitry Potapov <dpotapov@gmail.com>\nDate: Thu, 31 Jul 2008 21:10:26 +0400\nSubject: [PATCH] hash-object --no-filters\n\nThe --no-filters option makes git hash-object to work as there were no\ninput filters. This option is useful for importers such as git-svn to\nput new version of files as is even if autocrlf is set.\n---\n Documentation/git-hash-object.txt |    6 ++++++\n hash-object.c                     |    7 ++++++-\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt\nindex ac928e1..69a17c7 100644\n--- a/Documentation/git-hash-object.txt\n+++ b/Documentation/git-hash-object.txt\n@@ -35,6 +35,12 @@ OPTIONS\n --stdin-paths::\n \tRead file names from stdin instead of from the command-line.\n \n+--no-filters::\n+\tIf this option is given then the file is hashed as is ignoring\n+\tall filters specified in the configuration, including crlf\n+\tconversion. If the file is read from standard input then no\n+\tfilters is always implied.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\ndiff --git a/hash-object.c b/hash-object.c\nindex 46c06a9..1e7fe8a 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -8,6 +8,8 @@\n #include \"blob.h\"\n #include \"quote.h\"\n \n+static unsigned no_filters;\n+\n static void hash_object(const char *path, enum object_type type, int write_object)\n {\n \tint fd;\n@@ -16,7 +18,8 @@ static void hash_object(const char *path, enum object_type type, int write_objec\n \tfd = open(path, O_RDONLY);\n \tif (fd < 0 ||\n \t    fstat(fd, &st) < 0 ||\n-\t    index_fd(sha1, fd, &st, write_object, type, path))\n+\t    ((no_filters ? st.st_mode &= ~S_IFREG : 0),\n+\t     index_fd(sha1, fd, &st, write_object, type, path)))\n \t\tdie(write_object\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\n@@ -104,6 +107,8 @@ int main(int argc, char **argv)\n \t\t\t\t\tdie(\"Multiple --stdin arguments are not supported\");\n \t\t\t\thashstdin = 1;\n \t\t\t}\n+\t\t\telse if (!strcmp(argv[i], \"--no-filters\"))\n+\t\t\t\tno_filters = 1;\n \t\t\telse\n \t\t\t\tusage(hash_object_usage);\n \t\t}\n-- \n1.6.0.rc1.32.gc84cb\n"},{"id":"85857","messageId":"200808011023.32139.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"20080731104529.GE7008@dpotapov.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-08-01T03:23:31Z","receivedAt":"2008-08-01T03:23:31Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> It does not look to be true. I did the following test:\n...\n> which means that the autocrlf conversion is done for temporary\n> files created by perl. (I tested it on Linux and Windows/Cygwin).\n>\n> In any case, I believe the right solution should be adding a\n> new option to git-hash-object to disable any conversion.\n\nMy bad, I did not append full thoughts. git-hash-object DOES autocrlf \nconvertion but  it cant do it correctly. All it can do - is to autodetect \ntext files. My setup has .git/info/attributes file where all files but .cpp \nand .h are binary. While .cpp and .h are text files. In this case \ngit-hash-object do not know the real file name as far as git-svn use \ntemporary files.\n\nI dont think that disabling convertion is a good way. I really want to convert \nmy files. Possible solution is to pass two file names to git-hash-object: the \nreal file with content and the proposed file name in the working directory. \nIn this case git-hash-object will be able to make correct convertion.\n"},{"id":"85861","messageId":"7v63qluxsb.fsf@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"200808011023.32139.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-01T05:09:08Z","receivedAt":"2008-08-01T05:09:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexander Litvinov <litvinov2004@gmail.com> writes:\n\n> I dont think that disabling convertion is a good way. I really want to convert \n> my files. Possible solution is to pass two file names to git-hash-object: the \n> real file with content and the proposed file name in the working directory. \n> In this case git-hash-object will be able to make correct convertion.\n\nI think the optional parameter to say \"pretend the content is from this\npath\" makes sense even for (and especially for) hashing --stdin.\n"},{"id":"85870","messageId":"37fcd2780808010044m424f8d8en67a4e50363238e4d@mail.gmail.com","threadId":"14615","inReplyTo":"7v63qluxsb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T07:44:20Z","receivedAt":"2008-08-01T07:44:20Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 1, 2008 at 9:09 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Alexander Litvinov <litvinov2004@gmail.com> writes:\n>\n>> I dont think that disabling convertion is a good way. I really want to convert\n>> my files. Possible solution is to pass two file names to git-hash-object: the\n>> real file with content and the proposed file name in the working directory.\n>> In this case git-hash-object will be able to make correct convertion.\n>\n> I think the optional parameter to say \"pretend the content is from this\n> path\" makes sense even for (and especially for) hashing --stdin.\n\ngit-svn uses git hash-object --stdin-paths, which means that it reads\nfilenames from the  standard input, so one optional parameter cannot\nhelp here. Also, I am not sure how it can be useful for --stdin, which\ndoes not convert anything (it uses index_pipe, which does not call\nconvert_to_git).\n\nDmitry\n"},{"id":"85871","messageId":"37fcd2780808010047t4ae20168y65103e90897dd3f8@mail.gmail.com","threadId":"14615","inReplyTo":"200808011023.32139.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T07:47:46Z","receivedAt":"2008-08-01T07:47:46Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 1, 2008 at 7:23 AM, Alexander Litvinov\n<litvinov2004@gmail.com> wrote:\n>\n> I dont think that disabling convertion is a good way. I really want to convert\n> my files.\n\nTo being able to synchronize efficiently in both ways, you need to store\nfiles exactly as they were received from SVN then there will be no\nproblem with applying binary delta patch. All CRLF conversion should be\ndone on checkout and checkin from/to Git repository.\n\nDmitry\n"},{"id":"85874","messageId":"7vbq0dtawp.fsf@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"37fcd2780808010047t4ae20168y65103e90897dd3f8@mail.gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-01T08:08:38Z","receivedAt":"2008-08-01T08:08:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dmitry Potapov\" <dpotapov@gmail.com> writes:\n\n> On Fri, Aug 1, 2008 at 7:23 AM, Alexander Litvinov\n> <litvinov2004@gmail.com> wrote:\n>>\n>> I dont think that disabling convertion is a good way. I really want to convert\n>> my files.\n>\n> To being able to synchronize efficiently in both ways, you need to store\n> files exactly as they were received from SVN then there will be no\n> problem with applying binary delta patch. All CRLF conversion should be\n> done on checkout and checkin from/to Git repository.\n\nAhh,... if that is the philosophy, perhaps we can teach --stdin-paths to\noptionally open the file itself and use index_pipe() like --stdin codepath\ndoes?\n"},{"id":"85878","messageId":"37fcd2780808010224l68c2c717y5334a34d9de1de8d@mail.gmail.com","threadId":"14615","inReplyTo":"7vbq0dtawp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T09:24:56Z","receivedAt":"2008-08-01T09:24:56Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 1, 2008 at 12:08 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Dmitry Potapov\" <dpotapov@gmail.com> writes:\n>>\n>> To being able to synchronize efficiently in both ways, you need to store\n>> files exactly as they were received from SVN then there will be no\n>> problem with applying binary delta patch. All CRLF conversion should be\n>> done on checkout and checkin from/to Git repository.\n>\n> Ahh,... if that is the philosophy, perhaps we can teach --stdin-paths to\n> optionally open the file itself and use index_pipe() like --stdin codepath\n> does?\n\nIt is possible to do in this way, but it less efficient, because it uses\nindex_pipe, which does not know the actual size, so it reallocates the buffer\nas it reads data from the descriptor, while index_fd uses xmap() instead.\nSo I sent another solution yesterday:\nhttp://article.gmane.org/gmane.comp.version-control.git/90968\n\nIt is a bit hackish because I unset S_IFREG bit in st_mode to disable\nconversion. In fact, my question what would be a better way to tell index_fd\nto not do any conversion. If you think that it is better to use index_pipe,\nwhich does not any conversion than I will redo my patch to use it instead.\n\nDmitry\n"},{"id":"85889","messageId":"200808011811.06984.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"7vbq0dtawp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-08-01T11:11:06Z","receivedAt":"2008-08-01T11:11:06Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> To being able to synchronize efficiently in both ways, you need to store\n> files exactly as they were received from SVN then there will be no\n> problem with applying binary delta patch. All CRLF conversion should be\n> done on checkout and checkin from/to Git repository.\n\nSorry I have lost the mind flow here.\n\n1. We 'fetch' files from svn as is. Yes, we know that svn use delta to rebuild \noriginal file.\n2. We commit file to git. Right here we use git-hash-object. As I understand \nwe _have_ to do convertion CRLF->LF here.\n3. In some days we will checkout file from git and wil do LF->CRLF convertion.\n\nI thought this is a right workflow. \n- We could store original file too at step 2 somwhow to be able to use delta \nat step 1.\n- We can't skip convertion at step 2. Overwise git will store files with CRLF.\n\nAm I wrong ?\n"},{"id":"85892","messageId":"200808011827.11043.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"37fcd2780808010044m424f8d8en67a4e50363238e4d@mail.gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-08-01T11:27:10Z","receivedAt":"2008-08-01T11:27:10Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> git-svn uses git hash-object --stdin-paths, which means that it reads\n> filenames from the  standard input, so one optional parameter cannot\n> help here. \n\nWe could add some parameter ti git-hash-object to tell that we will pass two \nlines per each file: real file name and proposed file name in workdir.\n\nIn this case git-hash-object will be able to do proper convertion.\n\nThe main proble is the tracking original file from svn. Propably we could use \nsome special dir in worktree to store original file. Or we could make special \nbranch to track that files and second one to store converted files.\n"},{"id":"85898","messageId":"37fcd2780808010536v63b2ed2ak31c6d85f2822dc20@mail.gmail.com","threadId":"14615","inReplyTo":"200808011811.06984.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T12:36:54Z","receivedAt":"2008-08-01T12:36:54Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 1, 2008 at 3:11 PM, Alexander Litvinov\n<litvinov2004@gmail.com> wrote:\n>> To being able to synchronize efficiently in both ways, you need to store\n>> files exactly as they were received from SVN then there will be no\n>> problem with applying binary delta patch. All CRLF conversion should be\n>> done on checkout and checkin from/to Git repository.\n>\n> Sorry I have lost the mind flow here.\n>\n> 1. We 'fetch' files from svn as is. Yes, we know that svn use delta to rebuild\n> original file.\n> 2. We commit file to git. Right here we use git-hash-object. As I understand\n> we _have_ to do convertion CRLF->LF here.\n\nNo, you should do any conversion here. There are two reasons for that:\n1. If you do then you will not be able to apply binary patches later.\n2. You do not really need it if the SVN repository has correct eol settings,\nbecause all files that have svn:eol-style set to either 'native' or 'LF'\nwill have LF. Those that do not have svn:eol-style or have it to another\nvalue should not be subject to CRLF conversion at all.\n\nSo, I believe all files received from SVN should be stored as is. Import is\nnot about creating new commits, it is about getting history from another\nrepository as it is.\n\n> 3. In some days we will checkout file from git and wil do LF->CRLF convertion.\n\nIt is done only for files that do not have CRLF already.\n\n>\n> I thought this is a right workflow.\n> - We could store original file too at step 2 somwhow to be able to use delta\n> at step 1.\n> - We can't skip convertion at step 2. Overwise git will store files with CRLF.\n\nIt is okay for Git to store CRLF, because you want to treat them as\nbinary files.  If you want them being treated as text, you should change\nsvn:eol-style to 'native' for those files in SVN and then new versions\nof these files will have the right ending. It is how SVN client works.\n\nThe only problem is how to synchronize the SVN view which files are binary\nand which are text and what Git thinks about them.\n\nDmitry\n"},{"id":"85912","messageId":"7vmyjwserv.fsf@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"37fcd2780808010224l68c2c717y5334a34d9de1de8d@mail.gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-01T19:42:44Z","receivedAt":"2008-08-01T19:42:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dmitry Potapov\" <dpotapov@gmail.com> writes:\n\n> On Fri, Aug 1, 2008 at 12:08 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> \"Dmitry Potapov\" <dpotapov@gmail.com> writes:\n>>>\n>>> To being able to synchronize efficiently in both ways, you need to store\n>>> files exactly as they were received from SVN then there will be no\n>>> problem with applying binary delta patch. All CRLF conversion should be\n>>> done on checkout and checkin from/to Git repository.\n>>\n>> Ahh,... if that is the philosophy, perhaps we can teach --stdin-paths to\n>> optionally open the file itself and use index_pipe() like --stdin codepath\n>> does?\n>\n> It is possible to do in this way, but it less efficient, because it uses\n> index_pipe, which does not know the actual size, so it reallocates the buffer\n> as it reads data from the descriptor, while index_fd uses xmap() instead.\n> So I sent another solution yesterday:\n> http://article.gmane.org/gmane.comp.version-control.git/90968\n>\n> It is a bit hackish because...\n\nOk, earlier I was confused who was proposing what for what purpose, but\nthat one was not just \"a bit hackish\" but an unacceptable hack ;-)\n\nPerhaps you would want to do the s/write_object/flags/ conversion, like\nthis?\n\n--\n\n cache.h     |    9 ++++++---\n sha1_file.c |   15 +++++++++------\n 2 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 2475de9..39975fb 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -390,9 +390,12 @@ extern int ie_match_stat(const struct index_state *, struct cache_entry *, struc\n extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);\n \n extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);\n-extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);\n-extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);\n-extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);\n+\n+#define HASH_OBJECT_DO_CREATE 01\n+#define HASH_OBJECT_LITERALLY 02\n+extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int flags, enum object_type type, const char *path);\n+extern int index_pipe(unsigned char *sha1, int fd, const char *type, int flags);\n+extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int flags);\n extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);\n \n #define REFRESH_REALLY\t\t0x0001\t/* ignore_valid */\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e281c14..5def648 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2353,10 +2353,11 @@ int has_sha1_file(const unsigned char *sha1)\n \treturn has_loose_object(sha1);\n }\n \n-int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)\n+int index_pipe(unsigned char *sha1, int fd, const char *type, int flags)\n {\n \tstruct strbuf buf;\n \tint ret;\n+\tint write_object = flags & HASH_OBJECT_DO_CREATE;\n \n \tstrbuf_init(&buf, 0);\n \tif (strbuf_read(&buf, fd, 4096) < 0) {\n@@ -2375,9 +2376,11 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)\n \treturn ret;\n }\n \n-int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n+int index_fd(unsigned char *sha1, int fd, struct stat *st, int flags,\n \t     enum object_type type, const char *path)\n {\n+\tint write_object = flags & HASH_OBJECT_DO_CREATE;\n+\tint hash_literally = flags & HASH_OBJECT_LITERALLY;\n \tsize_t size = xsize_t(st->st_size);\n \tvoid *buf = NULL;\n \tint ret, re_allocated = 0;\n@@ -2392,7 +2395,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n \t/*\n \t * Convert blobs to git internal format\n \t */\n-\tif ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {\n+\tif (!hash_literally && (type == OBJ_BLOB) && S_ISREG(st->st_mode)) {\n \t\tstruct strbuf nbuf;\n \t\tstrbuf_init(&nbuf, 0);\n \t\tif (convert_to_git(path, buf, size, &nbuf,\n@@ -2416,7 +2419,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n \treturn ret;\n }\n \n-int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object)\n+int index_path(unsigned char *sha1, const char *path, struct stat *st, int flags)\n {\n \tint fd;\n \tchar *target;\n@@ -2428,7 +2431,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write\n \t\tif (fd < 0)\n \t\t\treturn error(\"open(\\\"%s\\\"): %s\", path,\n \t\t\t\t     strerror(errno));\n-\t\tif (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)\n+\t\tif (index_fd(sha1, fd, st, flags, OBJ_BLOB, path) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n@@ -2441,7 +2444,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write\n \t\t\treturn error(\"readlink(\\\"%s\\\"): %s\", path,\n \t\t\t             errstr);\n \t\t}\n-\t\tif (!write_object)\n+\t\tif (!(flags & HASH_OBJECT_DO_CREATE))\n \t\t\thash_sha1_file(target, len, blob_type, sha1);\n \t\telse if (write_sha1_file(target, len, blob_type, sha1))\n \t\t\treturn error(\"%s: failed to insert into database\",\n"},{"id":"85939","messageId":"20080801220932.GK7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"7vmyjwserv.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T22:09:32Z","receivedAt":"2008-08-01T22:09:32Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 01, 2008 at 12:42:44PM -0700, Junio C Hamano wrote:\n> \n> Ok, earlier I was confused who was proposing what for what purpose, but\n> that one was not just \"a bit hackish\" but an unacceptable hack ;-)\n\nThanks for correct my wording ;-)\n\n> \n> Perhaps you would want to do the s/write_object/flags/ conversion, like\n> this?\n\nYes, it was my prefered choice to change these index_xx functions.\n\nI have applied your patch and then corrected mine to use flags.\nSee below.\n\nI wonder if something should be done about other places where index_xx\nfunctions are called. I have looked at them and all they use either 0 or\n1 (boolean expression which will be evaluated to 0 or 1), so they should\nwork as is, but I can correct them to use HASH_OBJECT_DO_CREATE instead\nof 1 if it helps with readability.\n\n-- 8< --\n\nFrom: Dmitry Potapov <dpotapov@gmail.com>\nDate: Thu, 31 Jul 2008 21:10:26 +0400\nSubject: [PATCH] hash-object --no-filters\n\nThe --no-filters option makes git hash-object to work as there were no\ninput filters. This option is useful for importers such as git-svn to\nput new version of files as is even if autocrlf is set.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n Documentation/git-hash-object.txt |    6 ++++++\n hash-object.c                     |   28 +++++++++++++++-------------\n 2 files changed, 21 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt\nindex ac928e1..69a17c7 100644\n--- a/Documentation/git-hash-object.txt\n+++ b/Documentation/git-hash-object.txt\n@@ -35,6 +35,12 @@ OPTIONS\n --stdin-paths::\n \tRead file names from stdin instead of from the command-line.\n \n+--no-filters::\n+\tIf this option is given then the file is hashed as is ignoring\n+\tall filters specified in the configuration, including crlf\n+\tconversion. If the file is read from standard input then no\n+\tfilters is always implied.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\ndiff --git a/hash-object.c b/hash-object.c\nindex 46c06a9..2dd7283 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -8,7 +8,7 @@\n #include \"blob.h\"\n #include \"quote.h\"\n \n-static void hash_object(const char *path, enum object_type type, int write_object)\n+static void hash_object(const char *path, enum object_type type, int flags)\n {\n \tint fd;\n \tstruct stat st;\n@@ -16,23 +16,23 @@ static void hash_object(const char *path, enum object_type type, int write_objec\n \tfd = open(path, O_RDONLY);\n \tif (fd < 0 ||\n \t    fstat(fd, &st) < 0 ||\n-\t    index_fd(sha1, fd, &st, write_object, type, path))\n-\t\tdie(write_object\n+\t    index_fd(sha1, fd, &st, flags, type, path))\n+\t\tdie((flags & HASH_OBJECT_DO_CREATE)\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\n \tprintf(\"%s\\n\", sha1_to_hex(sha1));\n \tmaybe_flush_or_die(stdout, \"hash to stdout\");\n }\n \n-static void hash_stdin(const char *type, int write_object)\n+static void hash_stdin(const char *type, int flags)\n {\n \tunsigned char sha1[20];\n-\tif (index_pipe(sha1, 0, type, write_object))\n+\tif (index_pipe(sha1, 0, type, flags))\n \t\tdie(\"Unable to add stdin to database\");\n \tprintf(\"%s\\n\", sha1_to_hex(sha1));\n }\n \n-static void hash_stdin_paths(const char *type, int write_objects)\n+static void hash_stdin_paths(const char *type, int flags)\n {\n \tstruct strbuf buf, nbuf;\n \n@@ -45,7 +45,7 @@ static void hash_stdin_paths(const char *type, int write_objects)\n \t\t\t\tdie(\"line is badly quoted\");\n \t\t\tstrbuf_swap(&buf, &nbuf);\n \t\t}\n-\t\thash_object(buf.buf, type_from_string(type), write_objects);\n+\t\thash_object(buf.buf, type_from_string(type), flags);\n \t}\n \tstrbuf_release(&buf);\n \tstrbuf_release(&nbuf);\n@@ -58,7 +58,7 @@ int main(int argc, char **argv)\n {\n \tint i;\n \tconst char *type = blob_type;\n-\tint write_object = 0;\n+\tint flags = 0;\n \tconst char *prefix = NULL;\n \tint prefix_length = -1;\n \tint no_more_flags = 0;\n@@ -80,7 +80,7 @@ int main(int argc, char **argv)\n \t\t\t\t\tprefix_length =\n \t\t\t\t\t\tprefix ? strlen(prefix) : 0;\n \t\t\t\t}\n-\t\t\t\twrite_object = 1;\n+\t\t\t\tflags |= HASH_OBJECT_DO_CREATE;\n \t\t\t}\n \t\t\telse if (!strcmp(argv[i], \"--\")) {\n \t\t\t\tno_more_flags = 1;\n@@ -104,6 +104,8 @@ int main(int argc, char **argv)\n \t\t\t\t\tdie(\"Multiple --stdin arguments are not supported\");\n \t\t\t\thashstdin = 1;\n \t\t\t}\n+\t\t\telse if (!strcmp(argv[i], \"--no-filters\"))\n+\t\t\t\tflags |= HASH_OBJECT_LITERALLY;\n \t\t\telse\n \t\t\t\tusage(hash_object_usage);\n \t\t}\n@@ -116,21 +118,21 @@ int main(int argc, char **argv)\n \t\t\t}\n \n \t\t\tif (hashstdin) {\n-\t\t\t\thash_stdin(type, write_object);\n+\t\t\t\thash_stdin(type, flags);\n \t\t\t\thashstdin = 0;\n \t\t\t}\n \t\t\tif (0 <= prefix_length)\n \t\t\t\targ = prefix_filename(prefix, prefix_length,\n \t\t\t\t\t\t      arg);\n-\t\t\thash_object(arg, type_from_string(type), write_object);\n+\t\t\thash_object(arg, type_from_string(type), flags);\n \t\t\tno_more_flags = 1;\n \t\t}\n \t}\n \n \tif (stdin_paths)\n-\t\thash_stdin_paths(type, write_object);\n+\t\thash_stdin_paths(type, flags);\n \n \tif (hashstdin)\n-\t\thash_stdin(type, write_object);\n+\t\thash_stdin(type, flags);\n \treturn 0;\n }\n-- \n1.6.0.rc1.33.gb756f\n"},{"id":"85940","messageId":"7vr698qt6w.fsf@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"20080801220932.GK7008@dpotapov.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-01T22:14:15Z","receivedAt":"2008-08-01T22:14:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Potapov <dpotapov@gmail.com> writes:\n\n> I have applied your patch and then corrected mine to use flags.\n> See below.\n>\n> I wonder if something should be done about other places where index_xx\n> functions are called. I have looked at them and all they use either 0 or\n> 1 (boolean expression which will be evaluated to 0 or 1), so they should\n> work as is, but I can correct them to use HASH_OBJECT_DO_CREATE instead\n> of 1 if it helps with readability.\n\nEven though the patch was not compile tested, I did check the existing\ncall sites are giving only 0 or 1, but I think converting these \"please\nwrite -- I give you 1\" callers to pass the bitmask would be a sane thing\nto do.\n"},{"id":"85956","messageId":"20080801231024.GL7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"7vr698qt6w.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-01T23:10:24Z","receivedAt":"2008-08-01T23:10:24Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Aug 01, 2008 at 03:14:15PM -0700, Junio C Hamano wrote:\n> \n> Even though the patch was not compile tested, I did check the existing\n> call sites are giving only 0 or 1, but I think converting these \"please\n> write -- I give you 1\" callers to pass the bitmask would be a sane thing\n> to do.\n\nHere it goes. It turned out that there are only two places that actually\nneeds correction, while two others use '0'. I have run 'make test' and\nit's passed the tests.\n\n-- 8< --\nFrom: Dmitry Potapov <dpotapov@gmail.com>\nDate: Sat, 2 Aug 2008 02:56:45 +0400\nSubject: [PATCH] convert index_path callers to use bitmask instead of 1\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n builtin-update-index.c |    5 +++--\n read-cache.c           |    2 +-\n 2 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-update-index.c b/builtin-update-index.c\nindex 38eb53c..d3e212c 100644\n--- a/builtin-update-index.c\n+++ b/builtin-update-index.c\n@@ -85,7 +85,7 @@ static int process_lstat_error(const char *path, int err)\n \n static int add_one_path(struct cache_entry *old, const char *path, int len, struct stat *st)\n {\n-\tint option, size;\n+\tint option, flags, size;\n \tstruct cache_entry *ce;\n \n \t/* Was the old index entry already up-to-date? */\n@@ -99,7 +99,8 @@ static int add_one_path(struct cache_entry *old, const char *path, int len, stru\n \tfill_stat_cache_info(ce, st);\n \tce->ce_mode = ce_mode_from_stat(old, st->st_mode);\n \n-\tif (index_path(ce->sha1, path, st, !info_only))\n+\tflags = info_only ? 0 : HASH_OBJECT_DO_CREATE;\n+\tif (index_path(ce->sha1, path, st, flags))\n \t\treturn -1;\n \toption = allow_add ? ADD_CACHE_OK_TO_ADD : 0;\n \toption |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;\ndiff --git a/read-cache.c b/read-cache.c\nindex 2c03ec3..afd6005 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -550,7 +550,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \t\talias->ce_flags |= CE_ADDED;\n \t\treturn 0;\n \t}\n-\tif (index_path(ce->sha1, path, st, 1))\n+\tif (index_path(ce->sha1, path, st, HASH_OBJECT_DO_CREATE))\n \t\treturn error(\"unable to index file %s\", path);\n \tif (ignore_case && alias && different_name(ce, alias))\n \t\tce = create_alias_ce(ce, alias);\n-- \n1.6.0.rc1.34.gad373\n"},{"id":"85991","messageId":"7vmyjvnx76.fsf_-_@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"20080801220932.GK7008@dpotapov.dyndns.org","subject":"Re: [PATCH] hash-object --no-filters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-02T17:28:13Z","receivedAt":"2008-08-02T17:28:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Potapov <dpotapov@gmail.com> writes:\n\n> The --no-filters option makes git hash-object to work as there were no\n> input filters. This option is useful for importers such as git-svn to\n> put new version of files as is even if autocrlf is set.\n\nI think this is going in the right direction, but I have to wonder a few\nthings.\n\nFirst, on hash-object.\n\n (1) \"hash-object --stdin\" always hashes literally.  We may want to be\n     able to say \"The contents is this but pretend it came from this path\n     and apply the usual input rules\", perhaps with \"--path=\" option;\n\n (2) \"hash-object temporaryfile\" may want to honor the same \"--path\"\n     option;\n\n (3) \"hash-object --stdin-paths\" may want to get pair of paths (i.e. two\n     lines per entry) to do the same.\n\nIf we want to do the above, the existing low-level interface needs to be\nadjusted.\n\nindex_pipe() and index_fd() can learn to take an additional string\nparameter for attribute lookup to implement (1) and (2) above.  Perhaps\nthe string can be NULL to signal --no-filter behaviour, in which case the\nHASH_OBJECT_LITERALLY change may not be necessary for this codepath.\n\nindex_path() is a healper for add_to_index() which is used for normal\naddition of working tree entities, and I do not see an immediate need to\nteach it about this \"use this different path for attribute lookup\" at\nleast for now.\n\nBy the way, why do we have index_pipe() and index_fd() to begin with?  Is\nit because users of index_pipe() do not know what the path it is hashing\nand also the fd being a pipe we cannot mmap it?\n\nIf these two are the only reasons, then I wonder if we can:\n\n - accept NULL as path and stat parameters for callers without a filename\n   (which automatically implies we are doing a regular blob and we hash\n   literally); and\n\n - first try to mmap(), and if it fails fall back to the \"read once into\n   strbuf\" codepath to solve mmap-vs-pipe issue.\n\nI am not sure if such a unification of these two functions is useful,\nthough.\n"},{"id":"86040","messageId":"20080803054218.GM7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"7vmyjvnx76.fsf_-_@gitster.siamese.dyndns.org","subject":"Re: [PATCH] hash-object --no-filters","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T05:42:18Z","receivedAt":"2008-08-03T05:42:18Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Sat, Aug 02, 2008 at 10:28:13AM -0700, Junio C Hamano wrote:\n> Dmitry Potapov <dpotapov@gmail.com> writes:\n> \n> > The --no-filters option makes git hash-object to work as there were no\n> > input filters. This option is useful for importers such as git-svn to\n> > put new version of files as is even if autocrlf is set.\n> \n> I think this is going in the right direction, but I have to wonder a few\n> things.\n> \n> First, on hash-object.\n> \n>  (1) \"hash-object --stdin\" always hashes literally.  We may want to be\n>      able to say \"The contents is this but pretend it came from this path\n>      and apply the usual input rules\", perhaps with \"--path=\" option;\n\nIt makes sense.\n\n> \n>  (2) \"hash-object temporaryfile\" may want to honor the same \"--path\"\n>      option;\n\nAgreed.\n\n> \n>  (3) \"hash-object --stdin-paths\" may want to get pair of paths (i.e. two\n>      lines per entry) to do the same.\n\nI cannot come up with a good name for this option.\n\n> \n> If we want to do the above, the existing low-level interface needs to be\n> adjusted.\n> \n> index_pipe() and index_fd() can learn to take an additional string\n> parameter for attribute lookup to implement (1) and (2) above.\n\nindex_fd already has the 'path' parameter, which is used as hint for\nfor blob conversion.\n\n> Perhaps\n> the string can be NULL to signal --no-filter behaviour, in which case the\n> HASH_OBJECT_LITERALLY change may not be necessary for this codepath.\n\nSounds like a good idea :)\n\n> \n> By the way, why do we have index_pipe() and index_fd() to begin with?  Is\n> it because users of index_pipe() do not know what the path it is hashing\n> and also the fd being a pipe we cannot mmap it?\n\nindex_fd() does not need the path for anything but to choose filters.\nSo, if index_pipe supported filters, it would have the same parameter.\n\nThere is one more parameter that index_fd() has and index_pipe() does\nnot. It is 'struct stat'. So I decided to look what this parameter is\nused for in index_fd(), and it turned out for two things:\n- to determine the size that needs to mmap\n- to check whether the file is regular and if it is not then skip\n  convert_to_git().\n\nThat made me wonder whether index_fd() can be ever called for a non-\nregular file? I studied the source code and with the exception to git\nhash-object, which can pass anything what it can bed opened, in all\nother cases, we always call it for what is know as a regular file. In\nfact, it could be otherwise. It won't work for non-regular files. It\nis quite obvious that git hash-object for a directory will fail, but\nI wondered what would happen if I'd give it something different. For\ninstance, a named pipe (FIFO)\n\n $mkfifo fifofile\n $git hash-object\n <wait for the other process to start write to it>\n e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\n\ni.e. the same SHA-1 as for an empty file, and here is why: index_fd()\ntries to mmap the file descriptor and that obviously fails, but xmmap()\nhas this particular code:\n\n\tif (ret == MAP_FAILED) {\n\t\tif (!length)\n\t\t\treturn NULL;\n\napparently, it was workaround for empty files, but because st_size is 0\nfor pipes, index_fd treats any pipe as empty file!\n\n> \n> If these two are the only reasons, then I wonder if we can:\n> \n>  - accept NULL as path and stat parameters for callers without a filename\n>    (which automatically implies we are doing a regular blob and we hash\n>    literally); and\n\nI like this idea.\n\n> \n>  - first try to mmap(), and if it fails fall back to the \"read once into\n>    strbuf\" codepath to solve mmap-vs-pipe issue.\n\nI have an alternative proposal:\n\nBecause we have stat structure given as a parameter, we can always\ncheck whether the file is regular or not. If it is regular, we can use\nmmap() and if it is not then use \"read once into strbuf\" approach.\n\n> I am not sure if such a unification of these two functions is useful,\n> though.\n\nI have implemented this unification, and it reduces the code size,\nmakes git-hash-object to work with named pipes, and makes easier to\nadd the --path and --no-filters options, because there is no need\nto modify the index_fd interface anymore, and there is a single place\nwhere convert_to_git is invoked. So it looks like a good idea.\n\nHere is the patch:\n\n-- >8 --\nFrom: Dmitry Potapov <dpotapov@gmail.com>\nDate: Sun, 3 Aug 2008 08:39:16 +0400\nSubject: [PATCH] teach index_fd to work with pipes\n\nindex_fd can now work with file descriptors that are not normal files\nbut any readable file. If the given file descriptor is a regular file\nthen mmap() is used; for other files, strbuf_read is used.\n\nThe path parameter, which has been used as hint for filters, can be\nNULL now to indicate that the file should be hashed literally without\nany filter.\n\nThe index_pipe function is removed as redundant.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n cache.h       |    1 -\n hash-object.c |   29 +++++++++++--------------\n sha1_file.c   |   64 +++++++++++++++++++++++++++-----------------------------\n 3 files changed, 44 insertions(+), 50 deletions(-)\n\ngit-hash-object before\n   text    data     bss     dec     hex filename\n 148751    1332   93164  243247   3b62f git-hash-object\n\nand after patch\n   text    data     bss     dec     hex filename\n 148687    1332   93164  243183   3b5ef git-hash-object\n\n\ndiff --git a/cache.h b/cache.h\nindex 2475de9..68ce6e6 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -391,7 +391,6 @@ extern int ie_modified(const struct index_state *, struct cache_entry *, struct\n \n extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);\n extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);\n-extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);\n extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);\n extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);\n \ndiff --git a/hash-object.c b/hash-object.c\nindex 46c06a9..ce027b9 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -8,28 +8,25 @@\n #include \"blob.h\"\n #include \"quote.h\"\n \n-static void hash_object(const char *path, enum object_type type, int write_object)\n+static void hash_fd(int fd, const char *type, int write_object, const char *path)\n {\n-\tint fd;\n \tstruct stat st;\n \tunsigned char sha1[20];\n-\tfd = open(path, O_RDONLY);\n-\tif (fd < 0 ||\n-\t    fstat(fd, &st) < 0 ||\n-\t    index_fd(sha1, fd, &st, write_object, type, path))\n+\tif (fstat(fd, &st) < 0 ||\n+\t    index_fd(sha1, fd, &st, write_object, type_from_string(type), path))\n \t\tdie(write_object\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\n \tprintf(\"%s\\n\", sha1_to_hex(sha1));\n \tmaybe_flush_or_die(stdout, \"hash to stdout\");\n }\n-\n-static void hash_stdin(const char *type, int write_object)\n+static void hash_object(const char *path, const char *type, int write_object)\n {\n-\tunsigned char sha1[20];\n-\tif (index_pipe(sha1, 0, type, write_object))\n-\t\tdie(\"Unable to add stdin to database\");\n-\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n+\tint fd;\n+\tfd = open(path, O_RDONLY);\n+\tif (fd < 0)\n+\t\tdie(\"Cannot open %s\", path);\n+\thash_fd(fd, type, write_object, path);\n }\n \n static void hash_stdin_paths(const char *type, int write_objects)\n@@ -45,7 +42,7 @@ static void hash_stdin_paths(const char *type, int write_objects)\n \t\t\t\tdie(\"line is badly quoted\");\n \t\t\tstrbuf_swap(&buf, &nbuf);\n \t\t}\n-\t\thash_object(buf.buf, type_from_string(type), write_objects);\n+\t\thash_object(buf.buf, type, write_objects);\n \t}\n \tstrbuf_release(&buf);\n \tstrbuf_release(&nbuf);\n@@ -116,13 +113,13 @@ int main(int argc, char **argv)\n \t\t\t}\n \n \t\t\tif (hashstdin) {\n-\t\t\t\thash_stdin(type, write_object);\n+\t\t\t\thash_fd(0, type, write_object, NULL);\n \t\t\t\thashstdin = 0;\n \t\t\t}\n \t\t\tif (0 <= prefix_length)\n \t\t\t\targ = prefix_filename(prefix, prefix_length,\n \t\t\t\t\t\t      arg);\n-\t\t\thash_object(arg, type_from_string(type), write_object);\n+\t\t\thash_object(arg, type, write_object);\n \t\t\tno_more_flags = 1;\n \t\t}\n \t}\n@@ -131,6 +128,6 @@ int main(int argc, char **argv)\n \t\thash_stdin_paths(type, write_object);\n \n \tif (hashstdin)\n-\t\thash_stdin(type, write_object);\n+\t\thash_fd(0, type, write_object, NULL);\n \treturn 0;\n }\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e281c14..765a7e7 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2353,51 +2353,22 @@ int has_sha1_file(const unsigned char *sha1)\n \treturn has_loose_object(sha1);\n }\n \n-int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)\n+static int index_mem(unsigned char *sha1, void *buf, size_t size,\n+\t\t     int write_object, enum object_type type, const char *path)\n {\n-\tstruct strbuf buf;\n-\tint ret;\n-\n-\tstrbuf_init(&buf, 0);\n-\tif (strbuf_read(&buf, fd, 4096) < 0) {\n-\t\tstrbuf_release(&buf);\n-\t\treturn -1;\n-\t}\n-\n-\tif (!type)\n-\t\ttype = blob_type;\n-\tif (write_object)\n-\t\tret = write_sha1_file(buf.buf, buf.len, type, sha1);\n-\telse\n-\t\tret = hash_sha1_file(buf.buf, buf.len, type, sha1);\n-\tstrbuf_release(&buf);\n-\n-\treturn ret;\n-}\n-\n-int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n-\t     enum object_type type, const char *path)\n-{\n-\tsize_t size = xsize_t(st->st_size);\n-\tvoid *buf = NULL;\n \tint ret, re_allocated = 0;\n \n-\tif (size)\n-\t\tbuf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n-\tclose(fd);\n-\n \tif (!type)\n \t\ttype = OBJ_BLOB;\n \n \t/*\n \t * Convert blobs to git internal format\n \t */\n-\tif ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {\n+\tif ((type == OBJ_BLOB) && path) {\n \t\tstruct strbuf nbuf;\n \t\tstrbuf_init(&nbuf, 0);\n \t\tif (convert_to_git(path, buf, size, &nbuf,\n \t\t                   write_object ? safe_crlf : 0)) {\n-\t\t\tmunmap(buf, size);\n \t\t\tbuf = strbuf_detach(&nbuf, &size);\n \t\t\tre_allocated = 1;\n \t\t}\n@@ -2411,8 +2382,35 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n \t\tfree(buf);\n \t\treturn ret;\n \t}\n-\tif (size)\n+\treturn ret;\n+}\n+\n+int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n+\t     enum object_type type, const char *path)\n+{\n+\tsize_t size = xsize_t(st->st_size);\n+\tint ret;\n+\n+\tif (!S_ISREG(st->st_mode))\n+\t{\n+\t\tstruct strbuf sbuf;\n+\t\tstrbuf_init(&sbuf, 0);\n+\t\tif (strbuf_read(&sbuf, fd, 4096) >= 0)\n+\t\t\tret = index_mem(sha1, sbuf.buf, sbuf.len, write_object,\n+\t\t\t\t\ttype, path);\n+\t\telse\n+\t\t\tret = -1;\n+\t\tstrbuf_release(&sbuf);\n+\t}\n+\telse if (size)\n+\t{\n+\t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\t\tret = index_mem(sha1, buf, size, write_object, type, path);\n \t\tmunmap(buf, size);\n+\t}\n+\telse\n+\t\tret = index_mem(sha1, NULL, size, write_object, type, path);\n+\tclose(fd);\n \treturn ret;\n }\n \n-- \n1.6.0.rc1.53.gaeaa.dirty\n"},{"id":"86041","messageId":"20080803055602.GN7008@dpotapov.dyndns.org","threadId":"14615","inReplyTo":"20080803054218.GM7008@dpotapov.dyndns.org","subject":"Re: [PATCH] hash-object --no-filters","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T05:56:03Z","receivedAt":"2008-08-03T05:56:03Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Sun, Aug 03, 2008 at 09:42:18AM +0400, Dmitry Potapov wrote:\n> \n> Here is the patch:\n\nI am sorry, I forgot to commit a micro cleanup to my patch:\n\n@@ -2378,10 +2378,8 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size,\n \t\tret = write_sha1_file(buf, size, typename(type), sha1);\n \telse\n \t\tret = hash_sha1_file(buf, size, typename(type), sha1);\n-\tif (re_allocated) {\n+\tif (re_allocated)\n \t\tfree(buf);\n-\t\treturn ret;\n-\t}\n \treturn ret;\n }\n\nSo, here is the corrected version of my patch:\n\n-- >8 --\nFrom: Dmitry Potapov <dpotapov@gmail.com>\nDate: Sun, 3 Aug 2008 08:39:16 +0400\nSubject: [PATCH] teach index_fd to work with pipes\n\nindex_fd can now work with file descriptors that are not normal files\nbut any readable file. If the given file descriptor is a regular file\nthen mmap() is used; for other files, strbuf_read is used.\n\nThe path parameter, which has been used as hint for filters, can be\nNULL now to indicate that the file should be hashed literally without\nany filter.\n\nThe index_pipe function is removed as redundant.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n cache.h       |    1 -\n hash-object.c |   29 +++++++++++-------------\n sha1_file.c   |   66 ++++++++++++++++++++++++++------------------------------\n 3 files changed, 44 insertions(+), 52 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 2475de9..68ce6e6 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -391,7 +391,6 @@ extern int ie_modified(const struct index_state *, struct cache_entry *, struct\n \n extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);\n extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);\n-extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);\n extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);\n extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);\n \ndiff --git a/hash-object.c b/hash-object.c\nindex 46c06a9..ce027b9 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -8,28 +8,25 @@\n #include \"blob.h\"\n #include \"quote.h\"\n \n-static void hash_object(const char *path, enum object_type type, int write_object)\n+static void hash_fd(int fd, const char *type, int write_object, const char *path)\n {\n-\tint fd;\n \tstruct stat st;\n \tunsigned char sha1[20];\n-\tfd = open(path, O_RDONLY);\n-\tif (fd < 0 ||\n-\t    fstat(fd, &st) < 0 ||\n-\t    index_fd(sha1, fd, &st, write_object, type, path))\n+\tif (fstat(fd, &st) < 0 ||\n+\t    index_fd(sha1, fd, &st, write_object, type_from_string(type), path))\n \t\tdie(write_object\n \t\t    ? \"Unable to add %s to database\"\n \t\t    : \"Unable to hash %s\", path);\n \tprintf(\"%s\\n\", sha1_to_hex(sha1));\n \tmaybe_flush_or_die(stdout, \"hash to stdout\");\n }\n-\n-static void hash_stdin(const char *type, int write_object)\n+static void hash_object(const char *path, const char *type, int write_object)\n {\n-\tunsigned char sha1[20];\n-\tif (index_pipe(sha1, 0, type, write_object))\n-\t\tdie(\"Unable to add stdin to database\");\n-\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n+\tint fd;\n+\tfd = open(path, O_RDONLY);\n+\tif (fd < 0)\n+\t\tdie(\"Cannot open %s\", path);\n+\thash_fd(fd, type, write_object, path);\n }\n \n static void hash_stdin_paths(const char *type, int write_objects)\n@@ -45,7 +42,7 @@ static void hash_stdin_paths(const char *type, int write_objects)\n \t\t\t\tdie(\"line is badly quoted\");\n \t\t\tstrbuf_swap(&buf, &nbuf);\n \t\t}\n-\t\thash_object(buf.buf, type_from_string(type), write_objects);\n+\t\thash_object(buf.buf, type, write_objects);\n \t}\n \tstrbuf_release(&buf);\n \tstrbuf_release(&nbuf);\n@@ -116,13 +113,13 @@ int main(int argc, char **argv)\n \t\t\t}\n \n \t\t\tif (hashstdin) {\n-\t\t\t\thash_stdin(type, write_object);\n+\t\t\t\thash_fd(0, type, write_object, NULL);\n \t\t\t\thashstdin = 0;\n \t\t\t}\n \t\t\tif (0 <= prefix_length)\n \t\t\t\targ = prefix_filename(prefix, prefix_length,\n \t\t\t\t\t\t      arg);\n-\t\t\thash_object(arg, type_from_string(type), write_object);\n+\t\t\thash_object(arg, type, write_object);\n \t\t\tno_more_flags = 1;\n \t\t}\n \t}\n@@ -131,6 +128,6 @@ int main(int argc, char **argv)\n \t\thash_stdin_paths(type, write_object);\n \n \tif (hashstdin)\n-\t\thash_stdin(type, write_object);\n+\t\thash_fd(0, type, write_object, NULL);\n \treturn 0;\n }\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e281c14..fe863f5 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2353,51 +2353,22 @@ int has_sha1_file(const unsigned char *sha1)\n \treturn has_loose_object(sha1);\n }\n \n-int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)\n+static int index_mem(unsigned char *sha1, void *buf, size_t size,\n+\t\t     int write_object, enum object_type type, const char *path)\n {\n-\tstruct strbuf buf;\n-\tint ret;\n-\n-\tstrbuf_init(&buf, 0);\n-\tif (strbuf_read(&buf, fd, 4096) < 0) {\n-\t\tstrbuf_release(&buf);\n-\t\treturn -1;\n-\t}\n-\n-\tif (!type)\n-\t\ttype = blob_type;\n-\tif (write_object)\n-\t\tret = write_sha1_file(buf.buf, buf.len, type, sha1);\n-\telse\n-\t\tret = hash_sha1_file(buf.buf, buf.len, type, sha1);\n-\tstrbuf_release(&buf);\n-\n-\treturn ret;\n-}\n-\n-int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n-\t     enum object_type type, const char *path)\n-{\n-\tsize_t size = xsize_t(st->st_size);\n-\tvoid *buf = NULL;\n \tint ret, re_allocated = 0;\n \n-\tif (size)\n-\t\tbuf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n-\tclose(fd);\n-\n \tif (!type)\n \t\ttype = OBJ_BLOB;\n \n \t/*\n \t * Convert blobs to git internal format\n \t */\n-\tif ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {\n+\tif ((type == OBJ_BLOB) && path) {\n \t\tstruct strbuf nbuf;\n \t\tstrbuf_init(&nbuf, 0);\n \t\tif (convert_to_git(path, buf, size, &nbuf,\n \t\t                   write_object ? safe_crlf : 0)) {\n-\t\t\tmunmap(buf, size);\n \t\t\tbuf = strbuf_detach(&nbuf, &size);\n \t\t\tre_allocated = 1;\n \t\t}\n@@ -2407,12 +2378,37 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n \t\tret = write_sha1_file(buf, size, typename(type), sha1);\n \telse\n \t\tret = hash_sha1_file(buf, size, typename(type), sha1);\n-\tif (re_allocated) {\n+\tif (re_allocated)\n \t\tfree(buf);\n-\t\treturn ret;\n+\treturn ret;\n+}\n+\n+int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,\n+\t     enum object_type type, const char *path)\n+{\n+\tsize_t size = xsize_t(st->st_size);\n+\tint ret;\n+\n+\tif (!S_ISREG(st->st_mode))\n+\t{\n+\t\tstruct strbuf sbuf;\n+\t\tstrbuf_init(&sbuf, 0);\n+\t\tif (strbuf_read(&sbuf, fd, 4096) >= 0)\n+\t\t\tret = index_mem(sha1, sbuf.buf, sbuf.len, write_object,\n+\t\t\t\t\ttype, path);\n+\t\telse\n+\t\t\tret = -1;\n+\t\tstrbuf_release(&sbuf);\n \t}\n-\tif (size)\n+\telse if (size)\n+\t{\n+\t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\t\tret = index_mem(sha1, buf, size, write_object, type, path);\n \t\tmunmap(buf, size);\n+\t}\n+\telse\n+\t\tret = index_mem(sha1, NULL, size, write_object, type, path);\n+\tclose(fd);\n \treturn ret;\n }\n \n-- \n1.6.0.rc1.53.gf8e95\n"},{"id":"86077","messageId":"1217774182-28566-1-git-send-email-dpotapov@gmail.com","threadId":"14615","inReplyTo":"20080803055602.GN7008@dpotapov.dyndns.org","subject":"[PATCH 1/5] correct argument checking test for git hash-object","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T14:36:18Z","receivedAt":"2008-08-03T14:36:18Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"Because the file name given to stdin did not exist, git hash-object\nwill fail to open it and exit with non-zero error code even if there\nis no check of arguments. Thus the test may pass despite the obvious\nerror in argument checking.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n t/t1007-hash-object.sh |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh\nindex 1ec0535..6d505fa 100755\n--- a/t/t1007-hash-object.sh\n+++ b/t/t1007-hash-object.sh\n@@ -49,16 +49,16 @@ setup_repo\n # Argument checking\n \n test_expect_success \"multiple '--stdin's are rejected\" '\n-\ttest_must_fail git hash-object --stdin --stdin < example\n+\techo example | test_must_fail git hash-object --stdin --stdin\n '\n \n test_expect_success \"Can't use --stdin and --stdin-paths together\" '\n-\ttest_must_fail git hash-object --stdin --stdin-paths &&\n-\ttest_must_fail git hash-object --stdin-paths --stdin\n+\techo example | test_must_fail git hash-object --stdin --stdin-paths &&\n+\techo example | test_must_fail git hash-object --stdin-paths --stdin\n '\n \n test_expect_success \"Can't pass filenames as arguments with --stdin-paths\" '\n-\ttest_must_fail git hash-object --stdin-paths hello < example\n+\techo example | test_must_fail git hash-object --stdin-paths hello\n '\n \n # Behavior\n-- \n1.6.0.rc1.58.gacdf\n"},{"id":"86076","messageId":"1217774182-28566-2-git-send-email-dpotapov@gmail.com","threadId":"14615","inReplyTo":"1217774182-28566-1-git-send-email-dpotapov@gmail.com","subject":"[PATCH 2/5] correct usage help string for git-hash-object","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T14:36:19Z","receivedAt":"2008-08-03T14:36:19Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"The usage string is corrected to make it fit in 80 columns and to make it\nunequivocal about what options can be used with --stdin-paths.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n Documentation/git-hash-object.txt |    4 +++-\n hash-object.c                     |    3 ++-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt\nindex ac928e1..a4703ec 100644\n--- a/Documentation/git-hash-object.txt\n+++ b/Documentation/git-hash-object.txt\n@@ -8,7 +8,9 @@ git-hash-object - Compute object ID and optionally creates a blob from a file\n \n SYNOPSIS\n --------\n-'git hash-object' [-t <type>] [-w] [--stdin | --stdin-paths] [--] <file>...\n+[verse]\n+'git hash-object' [-t <type>] [-w] [--stdin] [--] <file>...\n+'git hash-object' [-t <type>] [-w] --stdin-paths < <list-of-paths>\n \n DESCRIPTION\n -----------\ndiff --git a/hash-object.c b/hash-object.c\nindex ce027b9..ac44b4e 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -49,7 +49,8 @@ static void hash_stdin_paths(const char *type, int write_objects)\n }\n \n static const char hash_object_usage[] =\n-\"git hash-object [ [-t <type>] [-w] [--stdin] <file>... | --stdin-paths < <list-of-paths> ]\";\n+\"git hash-object [-t <type>] [-w] [--stdin] [--] <file>...\\n\"\n+\"   or: git hash-object  --stdin-paths < <list-of-paths>\";\n \n int main(int argc, char **argv)\n {\n-- \n1.6.0.rc1.58.gacdf\n"},{"id":"86078","messageId":"1217774182-28566-3-git-send-email-dpotapov@gmail.com","threadId":"14615","inReplyTo":"1217774182-28566-2-git-send-email-dpotapov@gmail.com","subject":"[PATCH 3/5] use parse_options() in git hash-object","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T14:36:20Z","receivedAt":"2008-08-03T14:36:20Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n hash-object.c |  122 +++++++++++++++++++++++++--------------------------------\n 1 files changed, 53 insertions(+), 69 deletions(-)\n\ndiff --git a/hash-object.c b/hash-object.c\nindex ac44b4e..b658fae 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -7,6 +7,7 @@\n #include \"cache.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n+#include \"parse-options.h\"\n \n static void hash_fd(int fd, const char *type, int write_object, const char *path)\n {\n@@ -48,87 +49,70 @@ static void hash_stdin_paths(const char *type, int write_objects)\n \tstrbuf_release(&nbuf);\n }\n \n-static const char hash_object_usage[] =\n-\"git hash-object [-t <type>] [-w] [--stdin] [--] <file>...\\n\"\n-\"   or: git hash-object  --stdin-paths < <list-of-paths>\";\n+static const char * const hash_object_usage[] = {\n+\t\"git hash-object [-t <type>] [-w] [--stdin] [--] <file>...\",\n+\t\"git hash-object  --stdin-paths < <list-of-paths>\",\n+\tNULL\n+};\n \n-int main(int argc, char **argv)\n+static const char *type;\n+static int write_object;\n+static int hashstdin;\n+static int stdin_paths;\n+\n+static const struct option hash_object_options[] = {\n+\tOPT_STRING('t', NULL, &type, \"type\", \"object type\"),\n+\tOPT_BOOLEAN('w', NULL, &write_object, \"write the object into the object database\"),\n+\tOPT_BOOLEAN( 0 , \"stdin\", &hashstdin, \"read the object from stdin\"),\n+\tOPT_BOOLEAN( 0 , \"stdin-paths\", &stdin_paths, \"read file names from stdin\"),\n+\tOPT_END()\n+};\n+\n+int main(int argc, const char **argv)\n {\n \tint i;\n-\tconst char *type = blob_type;\n-\tint write_object = 0;\n \tconst char *prefix = NULL;\n \tint prefix_length = -1;\n-\tint no_more_flags = 0;\n-\tint hashstdin = 0;\n-\tint stdin_paths = 0;\n+\tconst char *errstr = NULL;\n+\n+\ttype = blob_type;\n \n \tgit_config(git_default_config, NULL);\n \n-\tfor (i = 1 ; i < argc; i++) {\n-\t\tif (!no_more_flags && argv[i][0] == '-') {\n-\t\t\tif (!strcmp(argv[i], \"-t\")) {\n-\t\t\t\tif (argc <= ++i)\n-\t\t\t\t\tusage(hash_object_usage);\n-\t\t\t\ttype = argv[i];\n-\t\t\t}\n-\t\t\telse if (!strcmp(argv[i], \"-w\")) {\n-\t\t\t\tif (prefix_length < 0) {\n-\t\t\t\t\tprefix = setup_git_directory();\n-\t\t\t\t\tprefix_length =\n-\t\t\t\t\t\tprefix ? strlen(prefix) : 0;\n-\t\t\t\t}\n-\t\t\t\twrite_object = 1;\n-\t\t\t}\n-\t\t\telse if (!strcmp(argv[i], \"--\")) {\n-\t\t\t\tno_more_flags = 1;\n-\t\t\t}\n-\t\t\telse if (!strcmp(argv[i], \"--help\"))\n-\t\t\t\tusage(hash_object_usage);\n-\t\t\telse if (!strcmp(argv[i], \"--stdin-paths\")) {\n-\t\t\t\tif (hashstdin) {\n-\t\t\t\t\terror(\"Can't use --stdin-paths with --stdin\");\n-\t\t\t\t\tusage(hash_object_usage);\n-\t\t\t\t}\n-\t\t\t\tstdin_paths = 1;\n-\n-\t\t\t}\n-\t\t\telse if (!strcmp(argv[i], \"--stdin\")) {\n-\t\t\t\tif (stdin_paths) {\n-\t\t\t\t\terror(\"Can't use %s with --stdin-paths\", argv[i]);\n-\t\t\t\t\tusage(hash_object_usage);\n-\t\t\t\t}\n-\t\t\t\tif (hashstdin)\n-\t\t\t\t\tdie(\"Multiple --stdin arguments are not supported\");\n-\t\t\t\thashstdin = 1;\n-\t\t\t}\n-\t\t\telse\n-\t\t\t\tusage(hash_object_usage);\n-\t\t}\n-\t\telse {\n-\t\t\tconst char *arg = argv[i];\n-\n-\t\t\tif (stdin_paths) {\n-\t\t\t\terror(\"Can't specify files (such as \\\"%s\\\") with --stdin-paths\", arg);\n-\t\t\t\tusage(hash_object_usage);\n-\t\t\t}\n-\n-\t\t\tif (hashstdin) {\n-\t\t\t\thash_fd(0, type, write_object, NULL);\n-\t\t\t\thashstdin = 0;\n-\t\t\t}\n-\t\t\tif (0 <= prefix_length)\n-\t\t\t\targ = prefix_filename(prefix, prefix_length,\n-\t\t\t\t\t\t      arg);\n-\t\t\thash_object(arg, type, write_object);\n-\t\t\tno_more_flags = 1;\n-\t\t}\n+\targc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);\n+\n+\tif (write_object) {\n+\t\tprefix = setup_git_directory();\n+\t\tprefix_length = prefix ? strlen(prefix) : 0;\n \t}\n \n-\tif (stdin_paths)\n-\t\thash_stdin_paths(type, write_object);\n+\tif (stdin_paths) {\n+\t\tif (hashstdin)\n+\t\t\terrstr = \"Can't use --stdin-paths with --stdin\";\n+\t\telse if (argc)\n+\t\t\terrstr = \"Can't specify files with --stdin-paths\";\n+\t}\n+\telse if (hashstdin > 1)\n+\t\terrstr = \"Multiple --stdin arguments are not supported\";\n+\n+\tif (errstr) {\n+\t\terror (errstr);\n+\t\tusage_with_options(hash_object_usage, hash_object_options);\n+\t}\n \n \tif (hashstdin)\n \t\thash_fd(0, type, write_object, NULL);\n+\n+\tfor (i = 0 ; i < argc; i++) {\n+\t\tconst char *arg = argv[i];\n+\n+\t\tif (0 <= prefix_length)\n+\t\t\targ = prefix_filename(prefix, prefix_length, arg);\n+\t\thash_object(arg, type, write_object);\n+\t}\n+\n+\tif (stdin_paths)\n+\t\thash_stdin_paths(type, write_object);\n+\n \treturn 0;\n }\n-- \n1.6.0.rc1.58.gacdf\n"},{"id":"86079","messageId":"1217774182-28566-4-git-send-email-dpotapov@gmail.com","threadId":"14615","inReplyTo":"1217774182-28566-3-git-send-email-dpotapov@gmail.com","subject":"[PATCH 4/5] add --path option to git hash-object","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T14:36:21Z","receivedAt":"2008-08-03T14:36:21Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"The --path option allows to make filters work as if the file specified\nwhile the actual its location may be different. It is mostly useful for\nhashing temporary files outside of the working directory.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n Documentation/git-hash-object.txt |   12 +++++++++++-\n hash-object.c                     |   19 +++++++++++++------\n t/t1007-hash-object.sh            |   24 ++++++++++++++++++++++++\n 3 files changed, 48 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt\nindex a4703ec..fececbf 100644\n--- a/Documentation/git-hash-object.txt\n+++ b/Documentation/git-hash-object.txt\n@@ -9,7 +9,7 @@ git-hash-object - Compute object ID and optionally creates a blob from a file\n SYNOPSIS\n --------\n [verse]\n-'git hash-object' [-t <type>] [-w] [--stdin] [--] <file>...\n+'git hash-object' [-t <type>] [-w] [--path=<file>] [--stdin] [--] <file>...\n 'git hash-object' [-t <type>] [-w] --stdin-paths < <list-of-paths>\n \n DESCRIPTION\n@@ -37,6 +37,16 @@ OPTIONS\n --stdin-paths::\n \tRead file names from stdin instead of from the command-line.\n \n+--path::\n+\tHash object as it were located at the given path. The location of\n+\tfile does not directly influence on the hash value, but path is\n+\tused to determine what git filters should be applied to the object\n+\tbefore it can be placed to the object database, and, as result of\n+\tapplying filters, the actual blob put into the object database may\n+\tdiffer from the given file. This option is mainly useful for hashing\n+\ttemporary files located outside of the working directory or files\n+\tread from stdin.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\ndiff --git a/hash-object.c b/hash-object.c\nindex b658fae..b11f459 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -21,13 +21,14 @@ static void hash_fd(int fd, const char *type, int write_object, const char *path\n \tprintf(\"%s\\n\", sha1_to_hex(sha1));\n \tmaybe_flush_or_die(stdout, \"hash to stdout\");\n }\n-static void hash_object(const char *path, const char *type, int write_object)\n+static void hash_object(const char *path, const char *type, int write_object,\n+\t\t\tconst char *vpath)\n {\n \tint fd;\n \tfd = open(path, O_RDONLY);\n \tif (fd < 0)\n \t\tdie(\"Cannot open %s\", path);\n-\thash_fd(fd, type, write_object, path);\n+\thash_fd(fd, type, write_object, vpath);\n }\n \n static void hash_stdin_paths(const char *type, int write_objects)\n@@ -43,14 +44,14 @@ static void hash_stdin_paths(const char *type, int write_objects)\n \t\t\t\tdie(\"line is badly quoted\");\n \t\t\tstrbuf_swap(&buf, &nbuf);\n \t\t}\n-\t\thash_object(buf.buf, type, write_objects);\n+\t\thash_object(buf.buf, type, write_objects, buf.buf);\n \t}\n \tstrbuf_release(&buf);\n \tstrbuf_release(&nbuf);\n }\n \n static const char * const hash_object_usage[] = {\n-\t\"git hash-object [-t <type>] [-w] [--stdin] [--] <file>...\",\n+\t\"git hash-object [-t <type>] [-w] [--path=<file>] [--stdin] [--] <file>...\",\n \t\"git hash-object  --stdin-paths < <list-of-paths>\",\n \tNULL\n };\n@@ -59,12 +60,14 @@ static const char *type;\n static int write_object;\n static int hashstdin;\n static int stdin_paths;\n+static const char *vpath;\n \n static const struct option hash_object_options[] = {\n \tOPT_STRING('t', NULL, &type, \"type\", \"object type\"),\n \tOPT_BOOLEAN('w', NULL, &write_object, \"write the object into the object database\"),\n \tOPT_BOOLEAN( 0 , \"stdin\", &hashstdin, \"read the object from stdin\"),\n \tOPT_BOOLEAN( 0 , \"stdin-paths\", &stdin_paths, \"read file names from stdin\"),\n+\tOPT_STRING( 0 , \"path\", &vpath, \"file\", \"process file as it were from this path\"),\n \tOPT_END()\n };\n \n@@ -84,6 +87,8 @@ int main(int argc, const char **argv)\n \tif (write_object) {\n \t\tprefix = setup_git_directory();\n \t\tprefix_length = prefix ? strlen(prefix) : 0;\n+\t\tif (vpath && prefix)\n+\t\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n \t}\n \n \tif (stdin_paths) {\n@@ -91,6 +96,8 @@ int main(int argc, const char **argv)\n \t\t\terrstr = \"Can't use --stdin-paths with --stdin\";\n \t\telse if (argc)\n \t\t\terrstr = \"Can't specify files with --stdin-paths\";\n+\t\telse if (vpath)\n+\t\t\terrstr = \"Can't use --stdin-paths with --path\";\n \t}\n \telse if (hashstdin > 1)\n \t\terrstr = \"Multiple --stdin arguments are not supported\";\n@@ -101,14 +108,14 @@ int main(int argc, const char **argv)\n \t}\n \n \tif (hashstdin)\n-\t\thash_fd(0, type, write_object, NULL);\n+\t\thash_fd(0, type, write_object, vpath);\n \n \tfor (i = 0 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (0 <= prefix_length)\n \t\t\targ = prefix_filename(prefix, prefix_length, arg);\n-\t\thash_object(arg, type, write_object);\n+\t\thash_object(arg, type, write_object, vpath ? vpath : arg);\n \t}\n \n \tif (stdin_paths)\ndiff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh\nindex 6d505fa..dbe1f04 100755\n--- a/t/t1007-hash-object.sh\n+++ b/t/t1007-hash-object.sh\n@@ -61,6 +61,10 @@ test_expect_success \"Can't pass filenames as arguments with --stdin-paths\" '\n \techo example | test_must_fail git hash-object --stdin-paths hello\n '\n \n+test_expect_success \"Can't use --path with --stdin-paths\" '\n+\techo example | test_must_fail git hash-object --stdin-paths --path=foo\n+'\n+\n # Behavior\n \n push_repo\n@@ -93,6 +97,26 @@ test_expect_success 'git hash-object --stdin file1 <file0 first operates on file\n \ttest \"$obname1\" = \"$obname1new\"\n '\n \n+test_expect_success 'check that approperiate filter is invoke when --path is used' '\n+\techo fooQ | tr Q \"\\\\015\" > file0 &&\n+\tcp file0 file1 &&\n+\techo \"file0 -crlf\" > .gitattributes &&\n+\techo \"file1 crlf\" >> .gitattributes &&\n+\tgit config core.autocrlf true &&\n+\tfile0_sha=$(git hash-object file0) &&\n+\tfile1_sha=$(git hash-object file1) &&\n+\ttest \"$file0_sha\" != \"$file1_sha\" &&\n+\tpath1_sha=$(git hash-object --path=file1 file0) &&\n+\tpath0_sha=$(git hash-object --path=file0 file1) &&\n+\ttest \"$file0_sha\" = \"$path0_sha\" &&\n+\ttest \"$file1_sha\" = \"$path1_sha\" &&\n+\tpath1_sha=$(cat file0 | git hash-object --path=file1 --stdin) &&\n+\tpath0_sha=$(cat file1 | git hash-object --path=file0 --stdin) &&\n+\ttest \"$file0_sha\" = \"$path0_sha\" &&\n+\ttest \"$file1_sha\" = \"$path1_sha\" &&\n+\tgit config --unset core.autocrlf\n+'\n+\n pop_repo\n \n for args in \"-w --stdin\" \"--stdin -w\"; do\n-- \n1.6.0.rc1.58.gacdf\n"},{"id":"86080","messageId":"1217774182-28566-5-git-send-email-dpotapov@gmail.com","threadId":"14615","inReplyTo":"1217774182-28566-4-git-send-email-dpotapov@gmail.com","subject":"[PATCH 5/5] add --no-filters option to git hash-object","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-03T14:36:22Z","receivedAt":"2008-08-03T14:36:22Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If this option is given then the file is hashed as is ignoring all filters\nspecified in the configuration. This option is incompatible with --path\nand --stdin-paths options.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n Documentation/git-hash-object.txt |    8 +++++++-\n hash-object.c                     |   17 +++++++++++++----\n t/t1007-hash-object.sh            |   24 ++++++++++++++++++++++++\n 3 files changed, 44 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt\nindex fececbf..340e49c 100644\n--- a/Documentation/git-hash-object.txt\n+++ b/Documentation/git-hash-object.txt\n@@ -9,7 +9,7 @@ git-hash-object - Compute object ID and optionally creates a blob from a file\n SYNOPSIS\n --------\n [verse]\n-'git hash-object' [-t <type>] [-w] [--path=<file>] [--stdin] [--] <file>...\n+'git hash-object' [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin] [--] <file>...\n 'git hash-object' [-t <type>] [-w] --stdin-paths < <list-of-paths>\n \n DESCRIPTION\n@@ -47,6 +47,12 @@ OPTIONS\n \ttemporary files located outside of the working directory or files\n \tread from stdin.\n \n+--no-filters::\n+\tIf this option is given then the file is hashed as is ignoring\n+\tall filters specified in the configuration, including crlf\n+\tconversion. If the file is read from standard input then no\n+\tfilters is always implied unless the --path option is given.\n+\n Author\n ------\n Written by Junio C Hamano <gitster@pobox.com>\ndiff --git a/hash-object.c b/hash-object.c\nindex b11f459..3070a3e 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -51,7 +51,7 @@ static void hash_stdin_paths(const char *type, int write_objects)\n }\n \n static const char * const hash_object_usage[] = {\n-\t\"git hash-object [-t <type>] [-w] [--path=<file>] [--stdin] [--] <file>...\",\n+\t\"git hash-object [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin] [--] <file>...\",\n \t\"git hash-object  --stdin-paths < <list-of-paths>\",\n \tNULL\n };\n@@ -60,6 +60,7 @@ static const char *type;\n static int write_object;\n static int hashstdin;\n static int stdin_paths;\n+static int no_filters;\n static const char *vpath;\n \n static const struct option hash_object_options[] = {\n@@ -67,6 +68,7 @@ static const struct option hash_object_options[] = {\n \tOPT_BOOLEAN('w', NULL, &write_object, \"write the object into the object database\"),\n \tOPT_BOOLEAN( 0 , \"stdin\", &hashstdin, \"read the object from stdin\"),\n \tOPT_BOOLEAN( 0 , \"stdin-paths\", &stdin_paths, \"read file names from stdin\"),\n+\tOPT_BOOLEAN( 0 , \"no-filters\", &no_filters, \"store file as is without filters\"),\n \tOPT_STRING( 0 , \"path\", &vpath, \"file\", \"process file as it were from this path\"),\n \tOPT_END()\n };\n@@ -98,9 +100,15 @@ int main(int argc, const char **argv)\n \t\t\terrstr = \"Can't specify files with --stdin-paths\";\n \t\telse if (vpath)\n \t\t\terrstr = \"Can't use --stdin-paths with --path\";\n+\t\telse if (no_filters)\n+\t\t\terrstr = \"Can't use --stdin-paths with --no-filters\";\n+\t}\n+\telse {\n+\t\tif (hashstdin > 1)\n+\t\t\terrstr = \"Multiple --stdin arguments are not supported\";\n+\t\tif (vpath && no_filters)\n+\t\t\terrstr = \"Can't use --path with --no-filters\";\n \t}\n-\telse if (hashstdin > 1)\n-\t\terrstr = \"Multiple --stdin arguments are not supported\";\n \n \tif (errstr) {\n \t\terror (errstr);\n@@ -115,7 +123,8 @@ int main(int argc, const char **argv)\n \n \t\tif (0 <= prefix_length)\n \t\t\targ = prefix_filename(prefix, prefix_length, arg);\n-\t\thash_object(arg, type, write_object, vpath ? vpath : arg);\n+\t\thash_object(arg, type, write_object,\n+\t\t\t    no_filters ? NULL : vpath ? vpath : arg);\n \t}\n \n \tif (stdin_paths)\ndiff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh\nindex dbe1f04..12195a5 100755\n--- a/t/t1007-hash-object.sh\n+++ b/t/t1007-hash-object.sh\n@@ -65,6 +65,14 @@ test_expect_success \"Can't use --path with --stdin-paths\" '\n \techo example | test_must_fail git hash-object --stdin-paths --path=foo\n '\n \n+test_expect_success \"Can't use --stdin-paths with --no-filters\" '\n+\techo example | test_must_fail git hash-object --stdin-paths --no-filters\n+'\n+\n+test_expect_success \"Can't use --path with --no-filters\" '\n+\ttest_must_fail git hash-object --no-filters --path=foo\n+'\n+\n # Behavior\n \n push_repo\n@@ -117,6 +125,22 @@ test_expect_success 'check that approperiate filter is invoke when --path is use\n \tgit config --unset core.autocrlf\n '\n \n+test_expect_success 'check that --no-filters option works' '\n+\techo fooQ | tr Q \"\\\\015\" > file0 &&\n+\tcp file0 file1 &&\n+\techo \"file0 -crlf\" > .gitattributes &&\n+\techo \"file1 crlf\" >> .gitattributes &&\n+\tgit config core.autocrlf true &&\n+\tfile0_sha=$(git hash-object file0) &&\n+\tfile1_sha=$(git hash-object file1) &&\n+\ttest \"$file0_sha\" != \"$file1_sha\" &&\n+\tnofilters_file1=$(git hash-object --no-filters file1) &&\n+\ttest \"$file0_sha\" = \"$nofilters_file1\" &&\n+\tnofilters_file1=$(cat file1 | git hash-object --stdin) &&\n+\ttest \"$file0_sha\" = \"$nofilters_file1\" &&\n+\tgit config --unset core.autocrlf\n+'\n+\n pop_repo\n \n for args in \"-w --stdin\" \"--stdin -w\"; do\n-- \n1.6.0.rc1.58.gacdf\n"},{"id":"86101","messageId":"7vod49u8us.fsf@gitster.siamese.dyndns.org","threadId":"14615","inReplyTo":"20080803055602.GN7008@dpotapov.dyndns.org","subject":"Re: [PATCH] hash-object --no-filters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-03T20:44:27Z","receivedAt":"2008-08-03T20:44:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Very nicely done; will queue along with the 5 patch series.\n\nThanks.\n"},{"id":"86134","messageId":"20080804004826.GB13019@untitled","threadId":"14615","inReplyTo":"200807311243.35219.litvinov2004@gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-08-04T00:48:26Z","receivedAt":"2008-08-04T00:48:26Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Alexander Litvinov <litvinov2004@gmail.com> wrote:\n> Make git-svn works with crlf (or any other) file content convertion enabled.\n> \n> When we modify file content SVN cant apply its delta to it. To fix this\n> situation I take full file content from SVN as next revision. This is\n> dump and slow but it works.\n\n> +\tmy $ctx = SVN::Client->new();\n> +\t$ctx->cat($fh, $url, $rev);\n>  }\n\nI know you've already (at least for now) pulled this patch but I won't\naccept anything that opens a second connection to the server.\n\nI've seen this in some svn:// servers intermittently, but I've seen\ngit-svn get its connection terminated whenever it opens a second\nconnection (it happens with parent-following).  git-svn used to do\nthis more frequently, but most of those cases got fixed (but\none remains with parent-following).\n\nAdditionally, git-svnimport and older versions of git-svn used the\nequivalent of $ctx->cat without deltas from the SVN::Ra object, so you\nshould be able todo something functionally equivalent w/o opening a new\nsocket.\n\n\n\nAs far as crlf issues with git-svn go, I'm blissfully ignorant of the\ncomplexities behind what git (or svn for that matter) does with crlf\nconversions[1].\n\nI'll be alright with any changes to git-svn that don't modify existing\nbehavior for crlf-ignorant users such as myself.  I'll trust Junio and\nother folks on the list to know and do what makes the most sense here.\n\n\n\n[1] I would have much rather preferred git didn't implement or care\n    about crlf filters at all, but maybe I'm just in a small minority.\n\n-- \nEric Wong\n"},{"id":"86143","messageId":"200808041010.38491.litvinov2004@gmail.com","threadId":"14615","inReplyTo":"37fcd2780808010536v63b2ed2ak31c6d85f2822dc20@mail.gmail.com","subject":"Re: [PATCH] git-svn now work with crlf convertion enabled.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2008-08-04T03:10:38Z","receivedAt":"2008-08-04T03:10:38Z","isPatch":true,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> 2. You do not really need it if the SVN repository has correct eol\n> settings, because all files that have svn:eol-style set to either 'native'\n> or 'LF' will have LF. Those that do not have svn:eol-style or have it to\n> another value should not be subject to CRLF conversion at all.\n>\n> So, I believe all files received from SVN should be stored as is. Import is\n> not about creating new commits, it is about getting history from another\n> repository as it is.\n\nI understand the idea now. Some of my files in svn repo are missing eol style \nproperty at all. Will fix this :-)\n\nThanks for help !\n"},{"id":"86336","messageId":"20080806111545.GD32184@machine.or.cz","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0807231356540.8986@racer","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-06T11:15:45Z","receivedAt":"2008-08-06T11:15:45Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Wed, Jul 23, 2008 at 01:57:54PM +0100, Johannes Schindelin wrote:\n> Note that you will have to do your digging using msysGit (i.e. the \n> developer's pack, not the installer for plain Git), since git-svn will be \n> removed from the next official \"Windows Git\" release, due to lack of \n> fixers.\n\n  is there any other problem with git-svn on Windows than the CRLF\nissue? I couldn't find anything significant in the issue tracker.\n\n  If not, why do you want to drop git-svn from Windows Git? It seems\nthat the CRLF issue has trivial workaround to set autocrlf=false;\nthis will make git-svn-tracked repositories useful only on Windows,\nbut I'd bet this is fine for large majority of Windows git-svn users?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe next generation of interesting software will be done\non the Macintosh, not the IBM PC.  -- Bill Gates\n"},{"id":"86340","messageId":"eaa105840808060535p783536b2i6f4036f6a67989a4@mail.gmail.com","threadId":"14615","inReplyTo":"20080806111545.GD32184@machine.or.cz","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Peter Harris","fromEmail":"peter@peter.is-a-geek.org","sentAt":"2008-08-06T12:35:25Z","receivedAt":"2008-08-06T12:35:25Z","isPatch":false,"sender":{"key":"peter@peter.is-a-geek.org","avatar":null},"body":"On Wed, Aug 6, 2008 at 7:15 AM, Petr Baudis wrote:\n> On Wed, Jul 23, 2008 at 01:57:54PM +0100, Johannes Schindelin wrote:\n>> Note that you will have to do your digging using msysGit (i.e. the\n>> developer's pack, not the installer for plain Git), since git-svn will be\n>> removed from the next official \"Windows Git\" release, due to lack of\n>> fixers.\n>\n>  is there any other problem with git-svn on Windows than the CRLF\n> issue? I couldn't find anything significant in the issue tracker.\n\nThe main problem currently is that git is Win32, and perl is Msys.\nWhen perl asks git to read files from /tmp (a path that doesn't exist\noutside Msys), it grinds to a screeching halt.\n\nThe quick and dirty fix is to convince git-svn to write temporary\nfiles somewhere else (maybe by passing DIR => $ENV{GIT_DIR} to\nFile::Temp::tempname, but I've been too embarrassed to suggest that\npublicly).\n\nThe correct fix is to switch the msysGit perl from Msys to Vanilla,\nbut I've been too lazy to finish that up (as the SVN modules quickly\ndescend into dependancy hell).\n\nPeter Harris\n"},{"id":"86341","messageId":"alpine.DEB.1.00.0808061436310.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14615","inReplyTo":"20080806111545.GD32184@machine.or.cz","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-06T12:43:51Z","receivedAt":"2008-08-06T12:43:51Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 6 Aug 2008, Petr Baudis wrote:\n\n> On Wed, Jul 23, 2008 at 01:57:54PM +0100, Johannes Schindelin wrote:\n> > Note that you will have to do your digging using msysGit (i.e. the \n> > developer's pack, not the installer for plain Git), since git-svn will \n> > be removed from the next official \"Windows Git\" release, due to lack \n> > of fixers.\n> \n>   is there any other problem with git-svn on Windows than the CRLF\n> issue? I couldn't find anything significant in the issue tracker.\n\nhttp://code.google.com/p/msysgit/issues/detail?id=120&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n\nIt is also frustrating that \n\nhttp://code.google.com/p/msysgit/issues/detail?id=83&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\nhttp://code.google.com/p/msysgit/issues/detail?id=103&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\nhttp://code.google.com/p/msysgit/issues/detail?id=129&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n\nare probably the same issue.  I cannot only blame the users for not really \nlooking if their issue has been reported yet; there are 32 open issues in \nmsysGit right now, number increasing, so it gets quite confusing.\n\nI once switched off the issue tracker, because I was the only one who took \nat least a little bit of care of it.  Due to list consensus, it was turned \nback on -- against my will.\n\nGuess who takes care of it right now?\n\nExactly.  So I will soon be switching it off again, I think, because there \nare few more useless things than an unmonitored issue tracker.\n\n>   If not, why do you want to drop git-svn from Windows Git? It seems \n> that the CRLF issue has trivial workaround to set autocrlf=false; this \n> will make git-svn-tracked repositories useful only on Windows, but I'd \n> bet this is fine for large majority of Windows git-svn users?\n\nIf it was so trivial, why does nobody use it?\n\nOh, and git-svn is slow, too.\n\nAnd _noone_ of those competent Windows git-svn users seemed fit or willing \nto do anything about git-svn, not even the simplest of issues.\n\nIf you want to do something about it, go ahead.  But I have no inclination \nof hearing from any Windows user about git-svn again, ever.\n\nCiao,\nDscho\n"},{"id":"86343","messageId":"20080806135100.GB10151@machine.or.cz","threadId":"14615","inReplyTo":"alpine.DEB.1.00.0808061436310.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"git-svn on MSysGit and why is it (going to be?) unsupported","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-06T13:51:00Z","receivedAt":"2008-08-06T13:51:00Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Hi!\n\nOn Wed, Aug 06, 2008 at 02:43:51PM +0200, Johannes Schindelin wrote:\n> On Wed, 6 Aug 2008, Petr Baudis wrote:\n> \n> > On Wed, Jul 23, 2008 at 01:57:54PM +0100, Johannes Schindelin wrote:\n> > > Note that you will have to do your digging using msysGit (i.e. the \n> > > developer's pack, not the installer for plain Git), since git-svn will \n> > > be removed from the next official \"Windows Git\" release, due to lack \n> > > of fixers.\n> > \n> >   is there any other problem with git-svn on Windows than the CRLF\n> > issue? I couldn't find anything significant in the issue tracker.\n> \n> http://code.google.com/p/msysgit/issues/detail?id=120&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n\nYes, that's why added the word \"significant\". ;-) This seems to be\nsimple module-out-of-sync issue.\n\n> It is also frustrating that \n> \n> http://code.google.com/p/msysgit/issues/detail?id=83&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n> http://code.google.com/p/msysgit/issues/detail?id=103&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n> http://code.google.com/p/msysgit/issues/detail?id=129&colspec=ID%20Type%20Status%20Priority%20Component%20Owner%20Summary\n> \n> are probably the same issue.  I cannot only blame the users for not really \n> looking if their issue has been reported yet; there are 32 open issues in \n> msysGit right now, number increasing, so it gets quite confusing.\n> \n> I once switched off the issue tracker, because I was the only one who took \n> at least a little bit of care of it.  Due to list consensus, it was turned \n> back on -- against my will.\n> \n> Guess who takes care of it right now?\n> \n> Exactly.  So I will soon be switching it off again, I think, because there \n> are few more useless things than an unmonitored issue tracker.\n\nWell, when looking through the tracker earlier today, I actually wanted\nto mark few dupes, but I did not find out how on the earth I'm supposed\nto do that. Either the operation is well-hidden in the web interface or\nI have to have some special rights to do that - in which case, it's no\nwonder the tracker is deteriorating.\n\n> >   If not, why do you want to drop git-svn from Windows Git? It seems \n> > that the CRLF issue has trivial workaround to set autocrlf=false; this \n> > will make git-svn-tracked repositories useful only on Windows, but I'd \n> > bet this is fine for large majority of Windows git-svn users?\n> \n> If it was so trivial, why does nobody use it?\n\nBecause it is not documented? Or is it? *Searches crlf in git-svn.html\nbundled with his msysgit* *Looks at Git FAQ* *Looks for release notes in\nthe start menu ... unsuccessfully* *Tries to Google out MSysGit release\nnotes ... unsuccessfully* *Founds MSysGit release notes sitting in\nProgram Files* \"git svn is slow or seems to be broken (see discussions\non the mailing list)\" What is \"the\" mailing list in MSysGit context?\n\n*Googles out MSysGit Google Group* *Searches git-svn and pages... and\npages.*\n\n\thttp://groups.google.com/group/msysgit/browse_thread/thread/8240da55a76f8c92/30656b448e9f5e74?lnk=gst&q=git-svn#30656b448e9f5e74\n\nOkay. That was really easy to find, wasn't it... Somewhere deep inside,\neven few mentions of autocrlf can be found.\n\n> Oh, and git-svn is slow, too.\n> \n> And _noone_ of those competent Windows git-svn users seemed fit or willing \n> to do anything about git-svn, not even the simplest of issues.\n\nI can of course understand that argument, even though it's a bit sad to\nsee when the issues are apparently either trivial or there is simple\nworkaround available. My trouble was that the _concrete_ reasons for\nthis are buried deep inside long mail threads (or threads on other\nmailing lists).\n\n> If you want to do something about it, go ahead.  But I have no inclination \n> of hearing from any Windows user about git-svn again, ever.\n\nNot currently, I'm just afraid I *might* have to sometime in the future.\n;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe next generation of interesting software will be done\non the Macintosh, not the IBM PC.  -- Bill Gates\n"},{"id":"86350","messageId":"32541b130808060823h2bda0ca0qfc21ea3b3403888a@mail.gmail.com","threadId":"14615","inReplyTo":"20080806135100.GB10151@machine.or.cz","subject":"Re: git-svn on MSysGit and why is it (going to be?) unsupported","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-08-06T15:23:13Z","receivedAt":"2008-08-06T15:23:13Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 8/6/08, Petr Baudis <pasky@suse.cz> wrote:\n>  On Wed, Aug 06, 2008 at 02:43:51PM +0200, Johannes Schindelin wrote:\n>  > And _noone_ of those competent Windows git-svn users seemed fit or willing\n>  > to do anything about git-svn, not even the simplest of issues.\n>\n>  I can of course understand that argument, even though it's a bit sad to\n>  see when the issues are apparently either trivial or there is simple\n>  workaround available. My trouble was that the _concrete_ reasons for\n>  this are buried deep inside long mail threads (or threads on other\n>  mailing lists).\n>\n>  > If you want to do something about it, go ahead.  But I have no inclination\n>  > of hearing from any Windows user about git-svn again, ever.\n>\n>  Not currently, I'm just afraid I *might* have to sometime in the future.\n>  ;-)\n\nFWIW (and related to the subject line in this thread), I think there\nare a lot of git users on Windows who just use the cygwin one.  That's\nwhat I do, and git-svn works fine (I don't use autocrlf though, which\nis probably why it worked).  git's support for both platforms, and the\nfact that cygwin was first and works already, probably greatly reduces\nthe number of developers who want to fix msysgit.\n\nHave fun,\n\nAvery\n"},{"id":"86357","messageId":"37fcd2780808060911g58fbab9ey6188280c8f318854@mail.gmail.com","threadId":"14615","inReplyTo":"20080806111545.GD32184@machine.or.cz","subject":"Re: git-svn does not seems to work with crlf convertion enabled.","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-08-06T16:11:25Z","receivedAt":"2008-08-06T16:11:25Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Wed, Aug 6, 2008 at 3:15 PM, Petr Baudis <pasky@suse.cz> wrote:\n>\n>  If not, why do you want to drop git-svn from Windows Git? It seems\n> that the CRLF issue has trivial workaround to set autocrlf=false;\n> this will make git-svn-tracked repositories useful only on Windows,\n> but I'd bet this is fine for large majority of Windows git-svn users?\n\nActually, it is not so simple. If you have svn properties setup correctly\nfor your text files (i.e. svn:eol-style=native) than autocrlf=false is\nnot what you want, because then SVN uses LF as EOL when stores this files.\n\nIn many case, just setting svn:eol-style correctly in SVN may solve the\nproblem.\n\nHowever, to make git-svn work reliable in present files with different\nending, it should import files from SVN  without applying any filter.\nTherefore, the --no-filters option was recently added to git-hash-object.\nAdding its use to git-svn should be easy (I have not had time to test it):\n===\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 087d3d0..438b7fd 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -829,7 +829,7 @@ sub _open_hash_and_insert_object_if_needed {\n\n        ($self->{hash_object_pid}, $self->{hash_object_in},\n         $self->{hash_object_out}, $self->{hash_object_ctx}) =\n-               command_bidi_pipe(qw(hash-object -w --stdin-paths));\n+               command_bidi_pipe(qw(hash-object -w --stdin-paths\n--no-filters));\n }\n\n sub _close_hash_and_insert_object {\n===\n\nThis should solve all problem with git-svn fetch. However, if you want to\nrespect svn:eol-style and when you commit your changes, that will require\nsynchronization svn:eol-style with values for crlf in your .gitattributes,\nwhich is a much more ambitious task.\n\nDmitry\n"}]}