Re: [PATCH 02/14] add_to_alternates_file: respect GIT_OBJECT_DIRECTORY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> 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@xxxxxxxxx>
> ---
> This is mainly for consistency / cleanliness.  I wouldn't mind
> dropping it.

I think this is a worthwhile thing to do, but you probably would
want to Cc author of nd/multiple-work-trees topic which would need
to address similar concern.

> 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.

"clone" is a bit special in that it needs to be careful about the
"local" case.  Does GIT_OBJECT_DIRECTORY (or GIT_DIR for that matter)
refer to the source or to the destination?

>  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");
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]