Git development
 help / color / mirror / Atom feed
* [PATCH] git-mv: fix directory separator treatment on Windows
@ 2009-06-30 13:33 Johannes Sixt
  2009-06-30 14:20 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Sixt @ 2009-06-30 13:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

From: Johannes Sixt <j6t@kdbg.org>

The following invocations did not work as expected on Windows:

    git mv foo\bar dest
    git mv foo\ dest

The first command was interpreted as

    git mv foo/bar dest/foo/bar

because the Windows style directory separator was not obeyed when the
basename of 'foo\bar' was computed.

The second command failed because the Windows style directory separator was
not removed from the source directory, whereupon the lookup of the
directory in the index failed.

This fixes both issues by using is_dir_sep() and basename().

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 builtin-mv.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/builtin-mv.c b/builtin-mv.c
index 8b81d4b..68f4738 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -24,14 +24,10 @@ static const char **copy_pathspec(const char *prefix,
 	result[count] = NULL;
 	for (i = 0; i < count; i++) {
 		int length = strlen(result[i]);
-		if (length > 0 && result[i][length - 1] == '/') {
+		if (length > 0 && is_dir_sep(result[i][length - 1]))
 			result[i] = xmemdupz(result[i], length - 1);
-		}
-		if (base_name) {
-			const char *last_slash = strrchr(result[i], '/');
-			if (last_slash)
-				result[i] = last_slash + 1;
-		}
+		if (base_name)
+			result[i] = basename((char *)result[i]);
 	}
 	return get_pathspec(prefix, result);
 }
-- 
1.6.3.3.1337.g9661167.dirty

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

* Re: [PATCH] git-mv: fix directory separator treatment on Windows
  2009-06-30 13:33 [PATCH] git-mv: fix directory separator treatment on Windows Johannes Sixt
@ 2009-06-30 14:20 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2009-06-30 14:20 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, Git Mailing List

Hi,

On Tue, 30 Jun 2009, Johannes Sixt wrote:

> From: Johannes Sixt <j6t@kdbg.org>
> 
> The following invocations did not work as expected on Windows:
> 
>     git mv foo\bar dest
>     git mv foo\ dest
> 
> The first command was interpreted as
> 
>     git mv foo/bar dest/foo/bar
> 
> because the Windows style directory separator was not obeyed when the
> basename of 'foo\bar' was computed.
> 
> The second command failed because the Windows style directory separator was
> not removed from the source directory, whereupon the lookup of the
> directory in the index failed.
> 
> This fixes both issues by using is_dir_sep() and basename().
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>

ACK

Dscho

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

end of thread, other threads:[~2009-06-30 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-30 13:33 [PATCH] git-mv: fix directory separator treatment on Windows Johannes Sixt
2009-06-30 14:20 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox