git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-mv: fully detect 'directory moved into itself'

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Nov 28, 2005, 09:15 UTC
Message-ID
<200511281015.15188.Josef.Weidendorfer@gmx.de>
In-Reply-To
<pan.2005.11.28.06.54.32.809941@smurf.noris.de>

This gives a better error message when trying to move a directory into some subdirectory of itself; ie. no real bug fix: renaming already failed before, but with a strange "invalid argument".

Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
---
This is a corrected version.
On Monday 28 November 2005 07:54, Matthias Urlichs wrote:
Show 10 quoted lines
> Hi, Josef Weidendorfer wrote:
> 
> > +    if (($bad eq "") && ($dst =~ /^$src\//)) {
> 
> That should be
> 
> > +    if (($bad eq "") && ($dst =~ /^\Q$src\E\//)) {
> 
> otherwise you will mistakenly match "foo-bar" with "foo.bar".
> 

Ah, thanks. You never end learning.

Josef
 git-mv.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

applies-to: 5d83477de7a407ab0ef183c6676114e1a507cf86 3c1ed8adaff3f7492ef2afdb5585ae7412a02817

diff --git a/git-mv.perl b/git-mv.perl
index ac19876..bfe3c29 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -108,7 +108,7 @@ while(scalar @srcArgs > 0) {
 	}
     }
     
-    if (($bad eq "") && ($src eq $dstDir)) {
+    if (($bad eq "") && ($dst =~ /^\Q$src\E\//)) {
 	$bad = "can not move directory '$src' into itself";
     }
 
---
0.99.9.GIT
Previous: Matthias UrlichsNext: Junio C Hamano
Message 3 of 4 in “git-mv: fully detect 'directory moved into itself'”
  1. Josef WeidendorferNov 27, 2005
  2. Matthias UrlichsNov 28, 2005
  3. git-mv: fully detect 'directory moved into itself'Josef Weidendorfer, Nov 28, 2005
  4. Junio C HamanoNov 28, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.