[PATCH 02/14] add_to_alternates_file: respect GIT_OBJECT_DIRECTORY
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Dec 3, 2014, 05:12 UTC
- Message-ID
- <20141203051220.GL6527@google.com>
- In-Reply-To
- <20141203050217.GJ6527@google.com>
The objects directory is spelled as get_object_directory(), not git_path("objects"). Some other code still hard-codes the objects/ directory name, so in the long term we may want to get rid of the pretense of support for GIT_OBJECT_DIRECTORY altogether, but this makes the code more consistent for now.
While at it, split variable declarations from the rest of the function. This makes the function a little easier to read, at the cost of some vertical space.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> --- This is mainly for consistency / cleanliness. I wouldn't mind dropping it.
The rest of 'git clone' is not careful about paying attention to GIT_OBJECT_DIRECTORY either. I suspect GIT_OBJECT_DIRECTORY was a bit of a failed experiment.
sha1_file.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c index d7f1838..e1945e2 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -403,9 +403,15 @@ void read_info_alternates(const char * relative_base, int depth) void add_to_alternates_file(const char *reference) { - struct lock_file *lock = xcalloc(1, sizeof(struct lock_file)); - int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), LOCK_DIE_ON_ERROR); - char *alt = mkpath("%s\n", reference); + struct lock_file *lock; + int fd; + char *alt; + + lock = xcalloc(1, sizeof(*lock)); + fd = hold_lock_file_for_append(lock, mkpath("%s/info/alternates", + get_object_directory()), + LOCK_DIE_ON_ERROR); + alt = mkpath("%s\n", reference); write_or_die(fd, alt, strlen(alt)); if (commit_lock_file(lock)) die("could not close alternates file");