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

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;
Previous: Junio C HamanoNext: Bryan Larsen
Message 3 of 4 in “patches to support working without the object database”
  1. Bryan LarsenJul 8, 2005
  2. Junio C HamanoJul 8, 2005
  3. Junio C HamanoJul 8, 2005
  4. Bryan LarsenJul 8, 2005

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

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