[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU global, do not resolve symlinks by default and use PWD if availa
From: |
dhruva |
Subject: |
Re: GNU global, do not resolve symlinks by default and use PWD if available |
Date: |
Mon, 23 Jun 2014 21:38:03 -0700 |
Perfect, that solves the issue and not alter the existing behavior.
Making it undocumented would be better as that gives us time to figure
out if there is a more elegant approach. Personally, I try to avoid
cluttering environment variable namespace as far as possible.
diff -d -u -r1.32 getdbpath.c
--- libutil/getdbpath.c 28 Feb 2014 04:08:11 -0000 1.32
+++ libutil/getdbpath.c 24 Jun 2014 04:37:18 -0000
@@ -211,7 +211,10 @@
char *p;
static char msg[1024];
- if (!getcwd(cwd, MAXPATHLEN)) {
+ /* Prefer shorter paths over long realpath if GTAGSLOGICALPATH is set */
+ if (getenv("GTAGSLOGICALPATH") && (p = getenv("PWD"))) {
+ strncpy(cwd, p, sizeof(cwd) - 1);
+ } else if (!getcwd(cwd, MAXPATHLEN)) {
gtags_dbpath_error = "cannot get current directory.";
return -1;
}
with best regards,
dhruva
On Mon, Jun 23, 2014 at 7:40 PM, Shigio YAMAGUCHI <address@hidden> wrote:
> Hello,
>> I use GNU global via emacs interface. My working directory root is a
>> symlink under which I have different SCM clients. The root provides
>> storage that is backed up.
>> I use recentf in emacs to store recently visited source files. GNU
>> global always resolves the symlinks and opens the file with the
>> 'realpath'. Many times this is very long and not so user friendly.
>>
>> I have a small fix that fixes this issue.
>
> Surely, we would sometimes often like to make a symbolic link of
> the project root directory. However, the specification change by your
> patch has high risk; we don't know what kind of influence comes
> out of it. Additionally, it is not desirable that operation is different
> depending on the environment.
>
> How about adding new environment variable GTAGSLOGICALPATH for the test?
> If this variable is set, GLOBAL use the value of PWD (if it is set)
> instead of getcwd(3).
>
> $ ln -s /tmp/a/b/c/d/e/f/g . # make a symbolic link
> $ cd g # move to the link
> $ global -ax main
> main 200 /tmp/a/b/c/d/e/f/g/main.c # physical path name
> $ export GTAGSLOGICALPATH=
> $ global -ax main
> main 200 /tmp/g/main.c # logical path name
>
> I would like to make it undocumented for a while. If there is no problem,
> I will make it a new specification.
>
> What do you think?
>
> --
> Shigio YAMAGUCHI <address@hidden>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663 C4B6 3CA5 BBB3 57BE DDA3