Re: patches to support working without the object database
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jul 8, 2005, 19:34 UTC
- Message-ID
- <7vpstt6qi7.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <7vwto16t6h.fsf@assigned-by-dhcp.cox.net>
Replying to myself...
JCH> While you are at it, you might also want to add an option to JCH> write-blob to specify the type of the object you are hashing, so JCH> that would make [*1*]:
JCH> git-write-blob [-n] [-t <type>] <file>...
JCH> [Footnote]
JCH> *1* I considered this instead:
JCH> git-write-blob [-n | -t <type>] <file>...
JCH> which means that if you specify type then -n is implied. But JCH> making -t independent would let you have inverse of JCH> git-cat-file; a silly example:
JCH> $ git-cat-file -t $FOO JCH> tree JCH> $ git-cat-file tree $FOO >tmp1 JCH> $ FOO1=$(git-write-blob -t tree tmp1)
JCH> If we go this route, we may also want to rename it to JCH> write-object, but I would want to have it as a separate patch JCH> after this series settles down.
Come to think of it, there is only one in-tree user of write-blob remaining. Renaming it to hash-object, changing the default behaviour to just hash without storing and instead give it --write (or just -w) flag would make more sense. Without -t, the type should default to "blob".
Then, the above stupid example would then become:
$ git-cat-file -t $FOO
tree
$ git-cat-file tree $FOO >tmp1
$ FOO1=$(git-hash-object -t tree tmp1)And the only in-tree user git-cvsimport-script would be changed to:
--- a/git-cvsimport-script +++ b/git-cvsimport-script @@ -683,7 +683,7 @@ while(<CVS>) { $fn =~ s#^/+##; my ($tmpname, $size) = $cvs->file($fn,$rev); print "".($init ? "New" : "Update")." $fn: $size bytes.\n" if $opt_v; - open my $F, '-|', "git-write-blob $tmpname" + open my $F, '-|', "git-hash-object -w $tmpname" or die "Cannot create object: $!\n"; my $sha = <$F>; chomp $sha;