* [PATCH] Make git-mv work in subdirectories, too
@ 2005-11-25 11:36 Johannes Schindelin
2005-11-26 2:45 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2005-11-25 11:36 UTC (permalink / raw)
To: git, junkio
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.
git-mv.perl | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
applies-to: 6b942d45a420cf8f4064f77713d9b218e7fa53cb
fa750ba9ea3a27b39c8931b18cf0e60a89bf9fd7
diff --git a/git-mv.perl b/git-mv.perl
index bf54c38..bb61add 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -34,7 +34,8 @@ EOT
}
# Sanity checks:
-my $GIT_DIR = $ENV{'GIT_DIR'} || ".git";
+my $GIT_DIR = `git-rev-parse --git-dir`;
+$GIT_DIR =~ s/\n$//;
unless ( -d $GIT_DIR && -d $GIT_DIR . "/objects" &&
-d $GIT_DIR . "/objects/" && -d $GIT_DIR . "/refs") {
---
0.99.9.GIT
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Make git-mv work in subdirectories, too
2005-11-25 11:36 [PATCH] Make git-mv work in subdirectories, too Johannes Schindelin
@ 2005-11-26 2:45 ` Junio C Hamano
2005-11-29 22:10 ` Alex Riesen
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2005-11-26 2:45 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 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;
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Make git-mv work in subdirectories, too
2005-11-26 2:45 ` Junio C Hamano
@ 2005-11-29 22:10 ` Alex Riesen
2005-11-30 14:50 ` Josef Weidendorfer
0 siblings, 1 reply; 4+ messages in thread
From: Alex Riesen @ 2005-11-29 22:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, git
Junio C Hamano, Sat, Nov 26, 2005 03:45:52 +0100:
> > 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.
It actually works in subdirs.
--- t/t4007-mv.sh
#!/bin/sh
test_description='git-mv in subdirs'
. ./test-lib.sh
test_expect_success \
'prepare reference tree' \
'mkdir path0 path1 &&
cp ../../COPYING path0/COPYING &&
git-add path0/COPYING &&
git-commit -m add -a'
test_expect_success \
'moving the file' \
'cd path0 && git-mv COPYING ../path1/COPYING'
# in path0 currently
test_expect_success \
'commiting the change' \
'cd .. && git-commit -m move -a'
test_expect_success \
'checking the commit' \
'git-diff-tree -r -M --name-status HEAD^ HEAD | \
grep -E "^R100.+path0/COPYING.+path1/COPYING"'
test_done
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Make git-mv work in subdirectories, too
2005-11-29 22:10 ` Alex Riesen
@ 2005-11-30 14:50 ` Josef Weidendorfer
0 siblings, 0 replies; 4+ messages in thread
From: Josef Weidendorfer @ 2005-11-30 14:50 UTC (permalink / raw)
To: git, Alex Riesen; +Cc: Junio C Hamano, Johannes Schindelin
On Tuesday 29 November 2005 23:10, Alex Riesen wrote:
> It actually works in subdirs.
>
> --- t/t4007-mv.sh
> test_expect_success \
> 'moving the file' \
> 'cd path0 && git-mv COPYING ../path1/COPYING'
Thanks for the test.
After moving to path1, you should check the other way, too:
cd path0 && git-mv ../path1/COPYING COPYING
And this currenly does *not* work because git-mv is only aware
of the git-controlled files in the subdirectory.
We probably also should check that source and target are in the
same git repo.
Josef
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-11-30 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-25 11:36 [PATCH] Make git-mv work in subdirectories, too Johannes Schindelin
2005-11-26 2:45 ` Junio C Hamano
2005-11-29 22:10 ` Alex Riesen
2005-11-30 14:50 ` Josef Weidendorfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox