* [PATCH] rename: allow full-path renames
@ 2015-06-22 16:23 Andreas Henriksson
2015-06-22 17:08 ` Sami Kerola
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Henriksson @ 2015-06-22 16:23 UTC (permalink / raw)
To: util-linux; +Cc: Andreas Henriksson, Andreas Henriksson
From: Andreas Henriksson <andreas.henriksson@endian.se>
The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work
before "allow renaming in subdirectories" change.
(regression in commit bd9ced628bb86)
Addresses: https://bugs.debian.org/789240
Reported-by: gregrwm <bug-grub@whitleymott.net>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
misc-utils/rename.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 7ac068d..c8a4f8c 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -92,10 +92,11 @@ static int do_symlink(char *from, char *to, char *s, int verbose)
static int do_file(char *from, char *to, char *s, int verbose)
{
- char *newname = NULL, *file;
+ char *newname = NULL, *file=NULL;
int ret = 1;
- file = strrchr(s, '/');
+ if (strchr(from, '/') == NULL && strchr(to, '/') == NULL)
+ file = strrchr(s, '/');
if (file == NULL)
file = s;
if (string_replace(from, to, file, s, &newname))
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] rename: allow full-path renames
2015-06-22 16:23 [PATCH] rename: allow full-path renames Andreas Henriksson
@ 2015-06-22 17:08 ` Sami Kerola
2015-06-22 17:22 ` [PATCH] tests: add fullpath tests to rename/subdir Andreas Henriksson
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Sami Kerola @ 2015-06-22 17:08 UTC (permalink / raw)
To: Andreas Henriksson; +Cc: util-linux, Andreas Henriksson
On 22 June 2015 at 17:23, Andreas Henriksson <andreas@fatal.se> wrote:
> The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work
> before "allow renaming in subdirectories" change.
> (regression in commit bd9ced628bb86)
>
> Addresses: https://bugs.debian.org/789240
> Reported-by: gregrwm <bug-grub@whitleymott.net>
> Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Hi Andreas,
Change looks good, but I would add a test to avoid same regression
happening in future. The same change with test can be found from
my git.
https://github.com/kerolasa/lelux-utiliteetit/commit/19ef4954935c65559e7561b4b3becbe462848127
--
Sami Kerola
http://www.iki.fi/kerolasa/
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH] tests: add fullpath tests to rename/subdir
2015-06-22 17:08 ` Sami Kerola
@ 2015-06-22 17:22 ` Andreas Henriksson
2015-06-25 10:03 ` Karel Zak
2015-06-22 17:26 ` [PATCH v2] rename: allow full-path renames Andreas Henriksson
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Andreas Henriksson @ 2015-06-22 17:22 UTC (permalink / raw)
To: util-linux; +Cc: Sami Kerola, Andreas Henriksson
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
tests/expected/rename/subdir | 9 +++++++++
tests/ts/rename/subdir | 24 ++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/tests/expected/rename/subdir b/tests/expected/rename/subdir
index a5b3dbe..f429602 100644
--- a/tests/expected/rename/subdir
+++ b/tests/expected/rename/subdir
@@ -18,3 +18,12 @@ renxme/aa
renxme/aa
renxme/aa
renxme/aa
+== fullpath ==
+`./rename_path1' -> `./rename_path2'
+./rename_path2
+`rename_path_test1' -> `rename_path_a/test1'
+./rename_path_a/test1
+`rename_path_a/test2' -> `rename_path_b/test2'
+rename_path_a
+rename_path_b
+rename_path_b/test2
diff --git a/tests/ts/rename/subdir b/tests/ts/rename/subdir
index 4ae7005..01472fa 100755
--- a/tests/ts/rename/subdir
+++ b/tests/ts/rename/subdir
@@ -41,4 +41,28 @@ done
rm -rf rename_a{a,b}
+echo "== fullpath ==" >> $TS_OUTPUT
+touch rename_path1
+$TS_CMD_RENAME -v ./rename_path1 ./rename_path2 ./rename_path1 >> $TS_OUTPUT 2>&1
+
+find . -name 'rename_path*' >> $TS_OUTPUT 2>&1
+rm -f ./rename_path*
+
+mkdir rename_path_a
+touch rename_path_test1
+
+$TS_CMD_RENAME -v rename_path_test1 rename_path_a/test1 rename_path_test1 >> $TS_OUTPUT 2>&1
+
+find . -name '*test1*' >> $TS_OUTPUT 2>&1
+rm -f rename_path_test1 rename_path_a/test1
+
+mkdir rename_path_b
+touch rename_path_a/test2
+$TS_CMD_RENAME -v rename_path_a/test2 rename_path_b/test2 rename_path_a/test2 >> $TS_OUTPUT 2>&1
+
+find rename_path_a rename_path_b >> $TS_OUTPUT 2>&1
+rm -f rename_path_a/test2 rename_path_b/test2
+
+rmdir rename_path_a rename_path_b
+
ts_finalize
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2] rename: allow full-path renames
2015-06-22 17:08 ` Sami Kerola
2015-06-22 17:22 ` [PATCH] tests: add fullpath tests to rename/subdir Andreas Henriksson
@ 2015-06-22 17:26 ` Andreas Henriksson
2015-06-25 10:04 ` Karel Zak
2015-06-22 17:29 ` [PATCH] " Andreas Henriksson
2015-06-25 10:06 ` Karel Zak
3 siblings, 1 reply; 8+ messages in thread
From: Andreas Henriksson @ 2015-06-22 17:26 UTC (permalink / raw)
To: util-linux; +Cc: Sami Kerola, Andreas Henriksson
The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work
before "allow renaming in subdirectories" change.
(regression in commit bd9ced628bb86)
Addresses: https://bugs.debian.org/789240
Reported-by: gregrwm <bug-grub@whitleymott.net>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
misc-utils/rename.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
v2: fixed my email address, add reviewed by.
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 7ac068d..c8a4f8c 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -92,10 +92,11 @@ static int do_symlink(char *from, char *to, char *s, int verbose)
static int do_file(char *from, char *to, char *s, int verbose)
{
- char *newname = NULL, *file;
+ char *newname = NULL, *file=NULL;
int ret = 1;
- file = strrchr(s, '/');
+ if (strchr(from, '/') == NULL && strchr(to, '/') == NULL)
+ file = strrchr(s, '/');
if (file == NULL)
file = s;
if (string_replace(from, to, file, s, &newname))
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] rename: allow full-path renames
2015-06-22 17:08 ` Sami Kerola
2015-06-22 17:22 ` [PATCH] tests: add fullpath tests to rename/subdir Andreas Henriksson
2015-06-22 17:26 ` [PATCH v2] rename: allow full-path renames Andreas Henriksson
@ 2015-06-22 17:29 ` Andreas Henriksson
2015-06-25 10:06 ` Karel Zak
3 siblings, 0 replies; 8+ messages in thread
From: Andreas Henriksson @ 2015-06-22 17:29 UTC (permalink / raw)
To: kerolasa; +Cc: util-linux
Hello Sami Kerola.
On Mon, Jun 22, 2015 at 06:08:53PM +0100, Sami Kerola wrote:
> Hi Andreas,
>
> Change looks good, but I would add a test to avoid same regression
> happening in future. The same change with test can be found from
> my git.
Thanks for your quick review. I was just about to send out the tests
I was writing which should now be in your inbox with hopefully a bit
more coverage...
Also submitted patch v2 with your Reviewed-by added.
Regards,
Andreas Henriksson
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rename: allow full-path renames
2015-06-22 17:08 ` Sami Kerola
` (2 preceding siblings ...)
2015-06-22 17:29 ` [PATCH] " Andreas Henriksson
@ 2015-06-25 10:06 ` Karel Zak
3 siblings, 0 replies; 8+ messages in thread
From: Karel Zak @ 2015-06-25 10:06 UTC (permalink / raw)
To: kerolasa; +Cc: Andreas Henriksson, util-linux, Andreas Henriksson
On Mon, Jun 22, 2015 at 06:08:53PM +0100, Sami Kerola wrote:
> Change looks good, but I would add a test to avoid same regression
> happening in future. The same change with test can be found from
> my git.
>
> https://github.com/kerolasa/lelux-utiliteetit/commit/19ef4954935c65559e7561b4b3becbe462848127
I have applied Andreas' test (but if you want to submit more tests
then go ahead :-)
Please, keep tests in the independent commits.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-06-25 10:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-22 16:23 [PATCH] rename: allow full-path renames Andreas Henriksson
2015-06-22 17:08 ` Sami Kerola
2015-06-22 17:22 ` [PATCH] tests: add fullpath tests to rename/subdir Andreas Henriksson
2015-06-25 10:03 ` Karel Zak
2015-06-22 17:26 ` [PATCH v2] rename: allow full-path renames Andreas Henriksson
2015-06-25 10:04 ` Karel Zak
2015-06-22 17:29 ` [PATCH] " Andreas Henriksson
2015-06-25 10:06 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox