Subject: Re: Dokumenting api-paths.txt

From: Jonathan Nieder <[email-masked]>
Date: Tue, 20 Aug 2013 14:59:11 -0700

Stefan Beller wrote:
>>> On 08/20/2013 03:31 PM, Johannes Sixt wrote:
>>>> Stefan Beller wrote:

>>>>> +    packdir = mkpathdup("%s/pack", get_object_directory());
>>>>> +    packtmp = mkpathdup("%s/.tmp-%d-pack", packdir, getpid());
>>>>
>>>> Should this not be
>>>>
>>>>     packdir = xstrdup(git_path("pack"));
>>>>     packtmp = xstrdup(git_path("pack/.tmp-%d-pack", getpid()));
[...]
> So if I have 
> 	packdir = xstrdup(git_path("pack"));
> 	...
> 	path = git_path("%s/%s", packdir, filename)
>
> This produces something as:
> .git/.git/objects/pack/.tmp-13199-pack-c59c5758ef159b272f6ab10cb9fadee443966e71.idx
> definitely having one .git too much.

The version with get_object_directory() was right.  The object
directory is not even necessarily under .git/, since it can be
overridden using the GIT_OBJECT_DIRECTORY envvar.

> Also interesting to add would be that git_path operates in the
> .git/objects directory?

git_path is for resolving paths within GIT_DIR, such as
git_path("config") and git_path("COMMIT_EDITMSG").

Jonathan