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

Re: [PATCH] Make git-mv work in subdirectories, too

From
Junio C Hamano <junkio@cox.net>
Date
Nov 26, 2005, 02:45 UTC
Message-ID
<7vmzjsdt3z.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0511251236060.30796@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 11 quoted lines
> Turns out, all git programs git-mv uses are capable of operating in
> a subdirectory just fine. So don't complain about it.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>
> ---
>
> 	I am no Perl guru, so this might not be the best way to go
> 	about it. Also, if people agree, I would like to remove the
> 	extra check for GIT_DIR validity, since git-rev-parse --git-dir
> 	does that already.

I think that sounds sane. You need to grab the exit status from `git-rev-parse --git-dir`, so the patch would become something like the attached. I haven't seriously used git-mv myself, so somebody needs to test it, and if it actually works and Ack on it, please.

---
diff --git a/git-mv.perl b/git-mv.perl
index bf54c38..6dda333 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -33,15 +33,9 @@ EOT
 	exit(1);
 }
 
-# Sanity checks:
-my $GIT_DIR = $ENV{'GIT_DIR'} || ".git";
-
-unless ( -d $GIT_DIR && -d $GIT_DIR . "/objects" && 
-	-d $GIT_DIR . "/objects/" && -d $GIT_DIR . "/refs") {
-    print "Git repository not found.";
-    usage();
-}
-
+my $GIT_DIR = `git rev-parse --git-dir`;
+exit 1 if $?; # rev-parse would have given "not a git dir" message.
+chomp($GIT_DIR);
 
 our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
 getopts("hnfkv") || usage;
Previous: Johannes SchindelinNext: Alex Riesen
Message 2 of 4 in “Make git-mv work in subdirectories, too”
  1. Make git-mv work in subdirectories, tooJohannes Schindelin, Nov 25, 2005
  2. Junio C HamanoNov 26, 2005
  3. Alex RiesenNov 29, 2005
  4. Josef WeidendorferNov 30, 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.