Re: [PATCH 36/47] rev-parse: prints --git-dir relative to user's cwd

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

 



2010/12/22 Junio C Hamano <gitster@xxxxxxxxx>:
> Nguyán ThÃi Ngác Duy Â<pclouds@xxxxxxxxx> writes:
>
>> git_dir variable in environment.c is relative to git's cwd, not user's
>> cwd. Convert the relative path (actualy by making it absolute path)
>> before printing out.
>>
>> Signed-off-by: Nguyán ThÃi Ngác Duy <pclouds@xxxxxxxxx>
>> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
>> ---
>> Âbuiltin/rev-parse.c | Â Â6 +++++-
>> Â1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
>> index a5a1c86..65c287b 100644
>> --- a/builtin/rev-parse.c
>> +++ b/builtin/rev-parse.c
>> @@ -647,7 +647,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â static char cwd[PATH_MAX];
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int len;
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (gitdir) {
>> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â puts(gitdir);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (is_absolute_path(gitdir) || !prefix) {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â puts(gitdir);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â puts(make_absolute_path(gitdir));
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (!prefix) {
>
> I do not quite understand this change. ÂI can obtain GIT_DIR in a relative
> form without this patch already:
>
> Â Â$ cd t/
> Â Â$ git --git-dir=../.git rev-parse --git-dir HEAD
> Â Â../.git
> Â Âc7511731675da8b50c0d5243aa04a98c8a5ee316
>
> Could we please have a new test case to demonstrate what is broken without
> this patch?
>

Um.. GIT_DIR can be changed by set_git_dir() inside
setup_directory_gently() and be relative to git's internal (movable)
cwd. The current code won't fall to that code path because GIT_DIR is
made absolute in most cases. A few cases we keep GIT_DIR relative,
we're sure cwd is not moved, or $GIT_DIR is not set and handled by
rev-parse code.

I reverted the patch and ran "make test". Passed. When an attempt to
make $GIT_DIR relative to worktree as much as possible happens, this
may be needed. But for now, I'm OK if you take this patch out. I'll
put it back on when I make such an attempt.
-- 
Duy
--
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]