* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 14:56 ` Junio C Hamano
@ 2013-07-29 16:07 ` Ramkumar Ramachandra
2013-07-29 17:29 ` Junio C Hamano
2013-07-30 0:27 ` Duy Nguyen
2013-07-30 10:21 ` Duy Nguyen
2 siblings, 1 reply; 10+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-29 16:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Nguyễn Thái Ngọc
Junio C Hamano wrote:
> That's a bit strange---the patch text looks like the "how about
> this" patch Duy posted earlier. Shouldn't it be From: Duy with
> S-o-b: by two of you instead?
Feel free to amend as you see fit, as always.
> For editors that are not broken, this could be an annoying
> regression, isn't it? When the user asks "What is the path of the
> file I am editing?" to the editor (i.e. an equivalent of \C-x\C-b),
> the updated code will start spewing a long full-path from the root
> directory, while we used to give a relative path that is short,
> sweet and more in line with the context of user's work.
Does it matter for COMMIT_EDITMSG or other files in $GITDIR? If
you're concerned about it, we can change the logic to: real_path() if
path-is-relative to avoid mangling the path in the non-submodules
case; in the submodules case, it will use an absolute-path, as before.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 16:07 ` Ramkumar Ramachandra
@ 2013-07-29 17:29 ` Junio C Hamano
2013-07-29 17:48 ` Ramkumar Ramachandra
0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2013-07-29 17:29 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git List, Nguyễn Thái Ngọc
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Junio C Hamano wrote:
>> That's a bit strange---the patch text looks like the "how about
>> this" patch Duy posted earlier. Shouldn't it be From: Duy with
>> S-o-b: by two of you instead?
>
> Feel free to amend as you see fit, as always.
I was asking what is "correct", without which I cannot "feel free"
to do anything, and your answer is not helping.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 17:29 ` Junio C Hamano
@ 2013-07-29 17:48 ` Ramkumar Ramachandra
2013-07-29 19:40 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-29 17:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Nguyễn Thái Ngọc
Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> Junio C Hamano wrote:
>>> That's a bit strange---the patch text looks like the "how about
>>> this" patch Duy posted earlier. Shouldn't it be From: Duy with
>>> S-o-b: by two of you instead?
>>
>> Feel free to amend as you see fit, as always.
>
> I was asking what is "correct", without which I cannot "feel free"
> to do anything, and your answer is not helping.
I don't have a strong opinion either way. Fwiw, I posted the original
with me as the author because I discovered it, dug through the emacs
sources for hours to find the exact bug, and contacted emacs-devel
about it. But no, I do not think there is anything "correct" about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 17:48 ` Ramkumar Ramachandra
@ 2013-07-29 19:40 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-07-29 19:40 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git List, Nguyễn Thái Ngọc
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> Junio C Hamano wrote:
>> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>>> Junio C Hamano wrote:
>>>> That's a bit strange---the patch text looks like the "how about
>>>> this" patch Duy posted earlier. Shouldn't it be From: Duy with
>>>> S-o-b: by two of you instead?
>>>
>>> Feel free to amend as you see fit, as always.
>>
>> I was asking what is "correct", without which I cannot "feel free"
>> to do anything, and your answer is not helping.
>
> I don't have a strong opinion either way.
There is no opinion involved. Maybe the word "correct" had a wrong
connotation, but what I needed to find out was a true provenance of
the change, as that is what the S-o-b chain records. I did not
know, and I needed to find out, if the patch in question was what
you came up independently without looking at Duy's patch (which is
very understandable as you two were going back and forth digging the
issue on the list), or you submitted his patch after tidying it up.
It appears from your description below that it was an independent
work, so that is what I'll queue.
Thanks.
> Fwiw, I posted the original
> with me as the author because I discovered it, dug through the emacs
> sources for hours to find the exact bug, and contacted emacs-devel
> about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 14:56 ` Junio C Hamano
2013-07-29 16:07 ` Ramkumar Ramachandra
@ 2013-07-30 0:27 ` Duy Nguyen
2013-07-30 13:48 ` Junio C Hamano
2013-07-30 10:21 ` Duy Nguyen
2 siblings, 1 reply; 10+ messages in thread
From: Duy Nguyen @ 2013-07-30 0:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ramkumar Ramachandra, Git List
On Mon, Jul 29, 2013 at 9:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Co-authored-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>
> That's a bit strange---the patch text looks like the "how about
> this" patch Duy posted earlier. Shouldn't it be From: Duy with
> S-o-b: by two of you instead?
The idea is the same, but my patch is a bit different (use of realpath
instead of real_path, I didn't remember git has real_path). I'm fine
with Ram being the author.
>> diff --git a/editor.c b/editor.c
>> index 27bdecd..0abbd8d 100644
>> --- a/editor.c
>> +++ b/editor.c
>> @@ -37,7 +37,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>> return error("Terminal is dumb, but EDITOR unset");
>>
>> if (strcmp(editor, ":")) {
>> - const char *args[] = { editor, path, NULL };
>> + const char *args[] = { editor, real_path(path), NULL };
>
> While I am not fundamentally opposed to add a workaround for bugs in
> a popular tool many people use, I am a bit uneasy about this change.
>
> For editors that are not broken, this could be an annoying
> regression, isn't it? When the user asks "What is the path of the
> file I am editing?" to the editor (i.e. an equivalent of \C-x\C-b),
> the updated code will start spewing a long full-path from the root
> directory, while we used to give a relative path that is short,
> sweet and more in line with the context of user's work.
>
> Compared to not being able to edit, it may be a small price to pay
> for those who do need to suffer the broken editor, but the patch
> makes those who do not need this workaround to pay the price.
Does looking at the edited file's path happen often? I have never done
that before. I ask because in order to avoid the price for those
users, the code could get a little bit more complicated (detecting if
the given relative path traverse backward outside a symlink..). To me
it seems like a good trade off in favor of simpler code.
--
Duy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-30 0:27 ` Duy Nguyen
@ 2013-07-30 13:48 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-07-30 13:48 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Ramkumar Ramachandra, Git List
Duy Nguyen <pclouds@gmail.com> writes:
> The idea is the same, but my patch is a bit different (use of realpath
> instead of real_path, I didn't remember git has real_path). I'm fine
> with Ram being the author.
Thanks, both of you, for clarification.
>> Compared to not being able to edit, it may be a small price to pay
>> for those who do need to suffer the broken editor, but the patch
>> makes those who do not need this workaround to pay the price.
>
> Does looking at the edited file's path happen often? I have never done
> that before. I ask because in order to avoid the price for those
> users, the code could get a little bit more complicated (detecting if
> the given relative path traverse backward outside a symlink..). To me
> it seems like a good trade off in favor of simpler code.
Yeah, I was being my usual cautious self, as somebody has to play
that role. I think the code as-is would be an OK trade off.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] editor: use canonicalized absolute path
2013-07-29 14:56 ` Junio C Hamano
2013-07-29 16:07 ` Ramkumar Ramachandra
2013-07-30 0:27 ` Duy Nguyen
@ 2013-07-30 10:21 ` Duy Nguyen
2 siblings, 0 replies; 10+ messages in thread
From: Duy Nguyen @ 2013-07-30 10:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ramkumar Ramachandra, Git List
On Mon, Jul 29, 2013 at 07:56:58AM -0700, Junio C Hamano wrote:
> > diff --git a/editor.c b/editor.c
> > index 27bdecd..0abbd8d 100644
> > --- a/editor.c
> > +++ b/editor.c
> > @@ -37,7 +37,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
> > return error("Terminal is dumb, but EDITOR unset");
> >
> > if (strcmp(editor, ":")) {
> > - const char *args[] = { editor, path, NULL };
> > + const char *args[] = { editor, real_path(path), NULL };
>
> While I am not fundamentally opposed to add a workaround for bugs in
> a popular tool many people use, I am a bit uneasy about this change.
>
> For editors that are not broken, this could be an annoying
> regression, isn't it? When the user asks "What is the path of the
> file I am editing?" to the editor (i.e. an equivalent of \C-x\C-b),
> the updated code will start spewing a long full-path from the root
> directory, while we used to give a relative path that is short,
> sweet and more in line with the context of user's work.
>
> Compared to not being able to edit, it may be a small price to pay
> for those who do need to suffer the broken editor, but the patch
> makes those who do not need this workaround to pay the price.
>
How about something like this? For standard setups, even if you have
symlink in cwd, it won't kick in because the given path is usually
.git/something (i.e. no ".." component)
-- 8< --
diff --git a/editor.c b/editor.c
index 27bdecd..02bf42c 100644
--- a/editor.c
+++ b/editor.c
@@ -37,10 +37,17 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
return error("Terminal is dumb, but EDITOR unset");
if (strcmp(editor, ":")) {
+ char cwd[PATH_MAX];
const char *args[] = { editor, path, NULL };
struct child_process p;
int ret, sig;
+ /* emacs workaround */
+ if (getcwd(cwd, PATH_MAX) &&
+ strcmp(real_path(cwd), cwd) &&
+ strstr(path, "../"))
+ args[1] = real_path(path);
+
memset(&p, 0, sizeof(p));
p.argv = args;
p.env = env;
-- 8<--
^ permalink raw reply related [flat|nested] 10+ messages in thread