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

Re: [PATCH] Ensure proper setup of git_dir for git-hash-object

From
Elijah Newren <newren@gmail.com>
Date
Feb 28, 2009, 21:20 UTC
Message-ID
<51419b2c0902281320neec7960vfbe7b806c8db56ca@mail.gmail.com>
In-Reply-To
<7v3adyffax.fsf@gitster.siamese.dyndns.org>
On Sat, Feb 28, 2009 at 1:59 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> newren@gmail.com writes:
>
>> Without this patch:
>> $ mkdir tmp
>> $ cd tmp/
>> $ git init --bare
>> Initialized empty Git repository in /home/newren/floss-development/git/tmp/
>> $ echo hi | git hash-object -w --stdin
>> error: unable to create temporary sha1 filename .git/objects/45: No such file or directory
>>
>> fatal: Unable to add stdin to database
>> $ echo hi | git --git-dir=. hash-object -w --stdin
>> 45b983be36b73c0788dc9cbcb76cbb80fc7bb057
>
> Does the patched version work without -w option?  Should it?

Yes, the patched version works with or without the -w option (at least in my testing -- maybe you know of a case I'm missing?) I would certainly expect it to work in both cases.

I basically arrived at the patch by realizing that git_config was setting git_dir incorrectly as a side-effect, causing setup_git_directory to notice it was already set and not try any of it's more detailed logic to figure out the correct value. Then I did some grepping and noticed that other source files (archive.c, builtin-apply.c, builtin-diff, etc., etc.) call setup_git_directory[_gently] before git_config, and that hash-object.c seemed to be the only one that didn't follow that trend.

Previous: Junio C HamanoNext: Elijah Newren
Message 3 of 4 in “Ensure proper setup of git_dir for git-hash-object”
  1. Ensure proper setup of git_dir for git-hash-objectnewren@gmail.com, Feb 28, 2009
  2. Junio C HamanoFeb 28, 2009
  3. Elijah NewrenFeb 28, 2009
  4. Elijah NewrenFeb 28, 2009

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.