All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Ignore duplicated slashes in git-log
@ 2008-02-09 12:54 Andi Kleen
  2008-02-09 13:24 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2008-02-09 12:54 UTC (permalink / raw)
  To: git


When I use git-log ... path/name  I seem to regularly
typo path/name as path//name (with duplicated slashes)
The normal kernel ignores these duplicated slashes
according to POSIX so it's typically no problem, but git 
fails and cannot find the correct file name when this
happens.

This patch fixes this case for git-log at least, by
handling duplicated slashes as a single slash. I probably
didn't change all places where file names are parsed
in the source base, but this seems to be a relatively common
place used by several sub commands. And at least for me
fixing git-log is the most important case anyways.

Patch against git 1.5.4

-Andi

diff -u git-1.5.4/setup.c-o git-1.5.4/setup.c
--- git-1.5.4/setup.c-o	2008-02-09 13:35:21.000000000 +0100
+++ git-1.5.4/setup.c	2008-02-09 13:47:53.000000000 +0100
@@ -7,6 +7,11 @@
 const char *prefix_path(const char *prefix, int len, const char *path)
 {
 	const char *orig = path;
+	char *s;
+
+	while ((s = strstr(path, "//")) != NULL)
+		memmove(s, s + 1, strlen(s));
+
 	for (;;) {
 		char c;
 		if (*path != '.')

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

* Re: [PATCH] Ignore duplicated slashes in git-log
  2008-02-09 12:54 [PATCH] Ignore duplicated slashes in git-log Andi Kleen
@ 2008-02-09 13:24 ` Johannes Schindelin
  2008-02-09 14:16   ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2008-02-09 13:24 UTC (permalink / raw)
  To: Andi Kleen; +Cc: git

Hi,

On Sat, 9 Feb 2008, Andi Kleen wrote:

> When I use git-log ... path/name I seem to regularly typo path/name as 
> path//name (with duplicated slashes) The normal kernel ignores these 
> duplicated slashes according to POSIX so it's typically no problem, but 
> git fails and cannot find the correct file name when this happens.

This is only one case you want to fix.  There are absolute paths, too, and 
series of "../".

Alas, Junio was quicker than you:

http://repo.or.cz/w/git.git?a=commitdiff;h=d089ebaad5315325d67db30176df1bbd7754fda9

Hth,
Dscho

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

* Re: [PATCH] Ignore duplicated slashes in git-log
  2008-02-09 13:24 ` Johannes Schindelin
@ 2008-02-09 14:16   ` Andi Kleen
  0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2008-02-09 14:16 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Andi Kleen, git

On Sat, Feb 09, 2008 at 01:24:56PM +0000, Johannes Schindelin wrote:
> Hi,
> 
> On Sat, 9 Feb 2008, Andi Kleen wrote:
> 
> > When I use git-log ... path/name I seem to regularly typo path/name as 
> > path//name (with duplicated slashes) The normal kernel ignores these 
> > duplicated slashes according to POSIX so it's typically no problem, but 
> > git fails and cannot find the correct file name when this happens.
> 
> This is only one case you want to fix.  There are absolute paths, too, and 
> series of "../".

It's hard to imagine anyone typoing sequences of ../ or ./, so at least
I personally didn't feel the need to handle that.

> 
> Alas, Junio was quicker than you:
> 
> http://repo.or.cz/w/git.git?a=commitdiff;h=d089ebaad5315325d67db30176df1bbd7754fda9

Great.

-Andi

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

end of thread, other threads:[~2008-02-09 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-09 12:54 [PATCH] Ignore duplicated slashes in git-log Andi Kleen
2008-02-09 13:24 ` Johannes Schindelin
2008-02-09 14:16   ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.