git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-gui: Few issues with using full path name
@ 2012-10-02 16:25 Andrew Wong
  2012-10-02 16:25 ` [PATCH 1/2] git-gui: Detect full path when parsing arguments Andrew Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andrew Wong @ 2012-10-02 16:25 UTC (permalink / raw)
  To: git; +Cc: Andrew Wong

I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try
to pass a full path to "git-gui blame", then "git-gui" will fail to detect the
argument as a valid path. The first patch will handle this scenario.

The second patch just another issue that I noticed when "git-gui" fails to
detect the file name. It'll then try to use the previously detected "head" as
the file name, while prepending it with "prefix". This is incorrect if "head"
is actually a full path.

There is also an issue when using a full path along with a rev argument, but I
don't have time to look it right now. I'll try to get to that issue another
time.

Andrew Wong (2):
  git-gui: Detect full path when parsing arguments
  git-gui: Don't prepend the prefix if value looks like a full path

 git-gui.sh | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

-- 
1.7.12.1.382.gb0576a6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] git-gui: Detect full path when parsing arguments
  2012-10-02 16:25 [PATCH] git-gui: Few issues with using full path name Andrew Wong
@ 2012-10-02 16:25 ` Andrew Wong
  2012-10-02 16:25 ` [PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path Andrew Wong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Wong @ 2012-10-02 16:25 UTC (permalink / raw)
  To: git; +Cc: Andrew Wong

When running "git-gui blame" from a subfolder (which means prefix is
non-empty), if we pass a full path as argument, the argument parsing
will fail to recognize the argument as a file name, because prefix is
prepended to the argument.

This patch handles that scenario by adding an additional branch that
checks the file name without using the prefix.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 git-gui.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/git-gui.sh b/git-gui.sh
index 5d035d5..5d7894b 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3003,10 +3003,19 @@ blame {
 	set jump_spec {}
 	set is_path 0
 	foreach a $argv {
-		if {$is_path || [file exists $_prefix$a]} {
+		if {[file exists $a]} {
+			if {$path ne {}} usage
+			set path [normalize_relpath $a]
+			break
+		} elseif {[file exists $_prefix$a]} {
 			if {$path ne {}} usage
 			set path [normalize_relpath $_prefix$a]
 			break
+		}
+
+		if {$is_path} {
+			if {$path ne {}} usage
+			break
 		} elseif {$a eq {--}} {
 			if {$path ne {}} {
 				if {$head ne {}} usage
-- 
1.7.12.1.382.gb0576a6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path
  2012-10-02 16:25 [PATCH] git-gui: Few issues with using full path name Andrew Wong
  2012-10-02 16:25 ` [PATCH 1/2] git-gui: Detect full path when parsing arguments Andrew Wong
@ 2012-10-02 16:25 ` Andrew Wong
  2012-10-07 21:25 ` [PATCH] git-gui: Few issues with using full path name Andrew Wong
  2012-10-12 14:08 ` Andrew Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Wong @ 2012-10-02 16:25 UTC (permalink / raw)
  To: git; +Cc: Andrew Wong

When argument parsing fails to detect a file name, "git-gui" will try to
use the previously detected "head" as the file name. We should avoid
prepending the prefix if "head" looks like a full path.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 git-gui.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 5d7894b..89f636f 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3037,8 +3037,13 @@ blame {
 	unset is_path
 
 	if {$head ne {} && $path eq {}} {
-		set path [normalize_relpath $_prefix$head]
-		set head {}
+		if {[string index $head 0] eq {/}} {
+			set path [normalize_relpath $head]
+			set head {}
+		} else {
+			set path [normalize_relpath $_prefix$head]
+			set head {}
+		}
 	}
 
 	if {$head eq {}} {
-- 
1.7.12.1.382.gb0576a6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-gui: Few issues with using full path name
  2012-10-02 16:25 [PATCH] git-gui: Few issues with using full path name Andrew Wong
  2012-10-02 16:25 ` [PATCH 1/2] git-gui: Detect full path when parsing arguments Andrew Wong
  2012-10-02 16:25 ` [PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path Andrew Wong
@ 2012-10-07 21:25 ` Andrew Wong
  2012-10-12 14:08 ` Andrew Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Wong @ 2012-10-07 21:25 UTC (permalink / raw)
  To: Andrew Wong; +Cc: git, spearce

Could we look into getting these two patches into git/git-gui?

On 10/02/12 12:25, Andrew Wong wrote:
> I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try
> to pass a full path to "git-gui blame", then "git-gui" will fail to detect the
> argument as a valid path. The first patch will handle this scenario.
>
> The second patch just another issue that I noticed when "git-gui" fails to
> detect the file name. It'll then try to use the previously detected "head" as
> the file name, while prepending it with "prefix". This is incorrect if "head"
> is actually a full path.
>
> There is also an issue when using a full path along with a rev argument, but I
> don't have time to look it right now. I'll try to get to that issue another
> time.
>
> Andrew Wong (2):
>   git-gui: Detect full path when parsing arguments
>   git-gui: Don't prepend the prefix if value looks like a full path
>
>  git-gui.sh | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-gui: Few issues with using full path name
  2012-10-02 16:25 [PATCH] git-gui: Few issues with using full path name Andrew Wong
                   ` (2 preceding siblings ...)
  2012-10-07 21:25 ` [PATCH] git-gui: Few issues with using full path name Andrew Wong
@ 2012-10-12 14:08 ` Andrew Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Wong @ 2012-10-12 14:08 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: Andrew Wong, git list

Can I get some feedback on these two patches? It'd be great to have them 
merged into git-gui. Thanks.


On 10/02/2012 12:25 PM, Andrew Wong wrote:
> I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try
> to pass a full path to "git-gui blame", then "git-gui" will fail to detect the
> argument as a valid path. The first patch will handle this scenario.
>
> The second patch just another issue that I noticed when "git-gui" fails to
> detect the file name. It'll then try to use the previously detected "head" as
> the file name, while prepending it with "prefix". This is incorrect if "head"
> is actually a full path.
>
> There is also an issue when using a full path along with a rev argument, but I
> don't have time to look it right now. I'll try to get to that issue another
> time.
>
> Andrew Wong (2):
>    git-gui: Detect full path when parsing arguments
>    git-gui: Don't prepend the prefix if value looks like a full path
>
>   git-gui.sh | 20 +++++++++++++++++---
>   1 file changed, 17 insertions(+), 3 deletions(-)
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-12 14:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-02 16:25 [PATCH] git-gui: Few issues with using full path name Andrew Wong
2012-10-02 16:25 ` [PATCH 1/2] git-gui: Detect full path when parsing arguments Andrew Wong
2012-10-02 16:25 ` [PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path Andrew Wong
2012-10-07 21:25 ` [PATCH] git-gui: Few issues with using full path name Andrew Wong
2012-10-12 14:08 ` Andrew Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).