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

Re: problem with git worktree and git svn

From
EWEric Wong <e@80x24.org>
Date
Oct 13, 2016, 20:55 UTC
Message-ID
<20161013205555.GA599@dcvr>
In-Reply-To
<CACsJy8ADmHLW5ba4bVTGN9ccqpMDNFgkqE_5JvnqZ0BxWcaCvw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> wrote:
Show 16 quoted lines
> On Thu, Oct 13, 2016 at 8:52 AM, Eric Wong <e@80x24.org> wrote:
> > +sub svn_dir {
> > +       my $git_dir = scalar @_ ? $_[0] : $ENV{GIT_DIR};
> > +       my $common = $ENV{GIT_COMMON_DIR} || "$git_dir/commondir";
> > +       $git_dir .= '/'.::file_to_s($common) if -e $common;
> > +       my $svn_dir = $git_dir . '/svn';
> > +       $svn_dir =~ tr!/!/!s;
> > +       $svn_dir;
> > +}
> 
> 
> If this is shell script, this function could be just
> 
> svn_dir() {
>     git rev-parse --git-path svn
> }
Ah, thanks; I missed --git-path.  I will do this in Git/SVN.pm:
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -808,12 +808,7 @@ sub get_fetch_range {
 }
 
 sub svn_dir {
-	my $git_dir = scalar @_ ? $_[0] : $ENV{GIT_DIR};
-	my $common = $ENV{GIT_COMMON_DIR} || "$git_dir/commondir";
-	$git_dir .= '/'.::file_to_s($common) if -e $common;
-	my $svn_dir = $git_dir . '/svn';
-	$svn_dir =~ tr!/!/!s;
-	$svn_dir;
+	command_oneline(qw(rev-parse --git-path svn));
 }
 
 sub tmp_config {

> which should give you correct path in either single or multi-worktree
> context and you don't need to bother with details like
> $GIT_COMMON_DIR. But I don't know how Perl bindings are implemented, I
> don't know if we have something similar (or easy to add it, like
> Git::git_path()).

I'm not sure it's necessary given the convenience of command_oneline,
and I'd rather avoid the overhead of documenting+supporting a new API
for Git.pm

> I don't know much about git-svn, but from the look of it I agree
> replacing $ENV{GIT_DIR}/svn with svn_dir() should fix it, assuming
> that you don't hard code $ENV{GIT_DIR}/blahblah somewhere else. I
> don't see any other potential problems (from multi-worktree
> perspective).

I think there was a place where $GIT_DIR/config was used, but
only for documentation purposes.
Previous: Duy NguyenNext: Eric Wong
Message 5 of 10 in “problem with git worktree and git svn”
  1. Mathieu ArnoldOct 12, 2016
  2. Stefan BellerOct 12, 2016
  3. Eric WongOct 13, 2016
  4. Duy NguyenOct 13, 2016
  5. Eric WongOct 13, 2016
  6. 0/2 git-svn: implement "git worktree" awarenessEric Wong, Oct 14, 2016
  7. 2/2 git-svn: "git worktree" awarenessEric Wong, Oct 14, 2016
  8. 1/2 git-svn: reduce scope of input record separator changeEric Wong, Oct 14, 2016
  9. Eric WongOct 26, 2016
  10. Junio C HamanoOct 26, 2016

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.