git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
	Git List <git@vger.kernel.org>
Subject: Re: [PATCH] editor: use canonicalized absolute path
Date: Tue, 30 Jul 2013 17:21:38 +0700	[thread overview]
Message-ID: <20130730102138.GA30476@lanh> (raw)
In-Reply-To: <7v8v0p2z45.fsf@alter.siamese.dyndns.org>

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

      parent reply	other threads:[~2013-07-30 10:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-28 16:59 [PATCH] editor: use canonicalized absolute path Ramkumar Ramachandra
2013-07-29 10:03 ` Duy Nguyen
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-29 17:48       ` Ramkumar Ramachandra
2013-07-29 19:40         ` Junio C Hamano
2013-07-30  0:27   ` Duy Nguyen
2013-07-30 13:48     ` Junio C Hamano
2013-07-30 10:21   ` Duy Nguyen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130730102138.GA30476@lanh \
    --to=pclouds@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).