summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1a97a50)
raw | patch | inline | side by side (parent: 1a97a50)
author | Eric Wong <normalperson@yhbt.net> | |
Tue, 20 Feb 2007 09:36:30 +0000 (01:36 -0800) | ||
committer | Eric Wong <normalperson@yhbt.net> | |
Fri, 23 Feb 2007 08:57:13 +0000 (00:57 -0800) |
If we are run inside a subdirectory of a working tree, we'll
chdir to the top first before touching anything. This also
prevents the accidental creation of .git directories inside
subdirectories since they need metadata.
Noticed by maio on #git
Signed-off-by: Eric Wong <normalperson@yhbt.net>
chdir to the top first before touching anything. This also
prevents the accidental creation of .git directories inside
subdirectories since they need metadata.
Noticed by maio on #git
Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl | patch | blob | history |
diff --git a/git-svn.perl b/git-svn.perl
index b4e8966919e67bc8aff3235aa2cd3da706dc928a..a6d98f1608f7a98d3368697717df380f2250686c 100755 (executable)
--- a/git-svn.perl
+++ b/git-svn.perl
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
$VERSION = '@@GIT_VERSION@@';
+my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
$ENV{GIT_DIR} ||= '.git';
$Git::SVN::default_repo_id = 'svn';
$Git::SVN::default_ref_id = $ENV{GIT_SVN_ID} || 'git-svn';
version() if $_version;
usage(1) unless defined $cmd;
load_authors() if $_authors;
+
+# make sure we're always running
+unless ($cmd =~ /(?:clone|init|multi-init)$/) {
+ unless (-d $ENV{GIT_DIR}) {
+ if ($git_dir_user_set) {
+ die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
+ "but it is not a directory\n";
+ }
+ my $git_dir = delete $ENV{GIT_DIR};
+ chomp(my $cdup = command_oneline(qw/rev-parse --show-cdup/));
+ unless (length $cdup) {
+ die "Already at toplevel, but $git_dir ",
+ "not found '$cdup'\n";
+ }
+ chdir $cdup or die "Unable to chdir up to '$cdup'\n";
+ unless (-d $git_dir) {
+ die "$git_dir still not found after going to ",
+ "'$cdup'\n";
+ }
+ $ENV{GIT_DIR} = $git_dir;
+ }
+}
unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
Git::SVN::Migration::migration_check();
}