{"thread":{"id":"19982","subject":"[PATCH] git-mv: fix directory separator treatment on Windows","startedAt":"2009-06-30T13:33:57Z","lastAt":"2009-06-30T14:20:51Z","messageCount":2,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"117232","messageId":"4A4A1445.6090704@viscovery.net","threadId":"19982","inReplyTo":null,"subject":"[PATCH] git-mv: fix directory separator treatment on Windows","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-06-30T13:33:57Z","receivedAt":"2009-06-30T13:33:57Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nThe following invocations did not work as expected on Windows:\n\n    git mv foo\\bar dest\n    git mv foo\\ dest\n\nThe first command was interpreted as\n\n    git mv foo/bar dest/foo/bar\n\nbecause the Windows style directory separator was not obeyed when the\nbasename of 'foo\\bar' was computed.\n\nThe second command failed because the Windows style directory separator was\nnot removed from the source directory, whereupon the lookup of the\ndirectory in the index failed.\n\nThis fixes both issues by using is_dir_sep() and basename().\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n builtin-mv.c |   10 +++-------\n 1 files changed, 3 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-mv.c b/builtin-mv.c\nindex 8b81d4b..68f4738 100644\n--- a/builtin-mv.c\n+++ b/builtin-mv.c\n@@ -24,14 +24,10 @@ static const char **copy_pathspec(const char *prefix,\n \tresult[count] = NULL;\n \tfor (i = 0; i < count; i++) {\n \t\tint length = strlen(result[i]);\n-\t\tif (length > 0 && result[i][length - 1] == '/') {\n+\t\tif (length > 0 && is_dir_sep(result[i][length - 1]))\n \t\t\tresult[i] = xmemdupz(result[i], length - 1);\n-\t\t}\n-\t\tif (base_name) {\n-\t\t\tconst char *last_slash = strrchr(result[i], '/');\n-\t\t\tif (last_slash)\n-\t\t\t\tresult[i] = last_slash + 1;\n-\t\t}\n+\t\tif (base_name)\n+\t\t\tresult[i] = basename((char *)result[i]);\n \t}\n \treturn get_pathspec(prefix, result);\n }\n-- \n1.6.3.3.1337.g9661167.dirty\n"},{"id":"117235","messageId":"alpine.DEB.1.00.0906301620370.4773@pacific.mpi-cbg.de","threadId":"19982","inReplyTo":"4A4A1445.6090704@viscovery.net","subject":"Re: [PATCH] git-mv: fix directory separator treatment on Windows","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-30T14:20:51Z","receivedAt":"2009-06-30T14:20:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 30 Jun 2009, Johannes Sixt wrote:\n\n> From: Johannes Sixt <j6t@kdbg.org>\n> \n> The following invocations did not work as expected on Windows:\n> \n>     git mv foo\\bar dest\n>     git mv foo\\ dest\n> \n> The first command was interpreted as\n> \n>     git mv foo/bar dest/foo/bar\n> \n> because the Windows style directory separator was not obeyed when the\n> basename of 'foo\\bar' was computed.\n> \n> The second command failed because the Windows style directory separator was\n> not removed from the source directory, whereupon the lookup of the\n> directory in the index failed.\n> \n> This fixes both issues by using is_dir_sep() and basename().\n> \n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n\nACK\n\nDscho\n"}]}