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

Re: git-svn: handling merge-base failures

From
Andrew Myrick <amyrick@apple.com>
Date
Dec 23, 2009, 20:18 UTC
Message-ID
<940F72F6-8FE5-42AE-84A1-8C4A77B57188@apple.com>
In-Reply-To
<20091223200936.GA13735@dcvr.yhbt.net>
On Dec 23, 2009, at 12:09 PM, Eric Wong wrote:
Show 25 quoted lines
> Andrew Myrick <amyrick@apple.com> wrote:
>> One of my projects is failing to clone because merge-base is failing
>> on one of the revisions; the branch is a partial branch, so merge-base
>> can't find a common ancestor with trunk.  I'd like to catch the
>> exception that command_oneline should throw when merge-base fails, but
>> my perl is very rusty and I'm struggling to get git-svn.perl to grok
>> the Git::Error::Command class.  What is the appropriate way to import
>> that class?  Or more generally, is there a better solution to handling
>> this error case?
> 
> Hi Andrew,
> 
> Git::Error::Command should be imported with the rest of Git.pm
> 
> It's a special way of doing exceptions in Perl which I don't see much
> point of...  Looking at git-send-email as an example, it does this:
> 
> 	use Error qw(:try);
> 	use Git;
> 
> 	try {
> 		# something that will throw
> 	} catch Git::Error::Command with {
> 		# error handling
> 	}
I looked at git-send-email's example, but I wanted to do a bit more:
	
	try {
		# command_oneline(...);
	} catch Git::Error::Command with {
		$E = shift;
		if ($E->value() == 1) {
			# do something
		} else {
			# do something else
		}
	}
	
This is used in perl/Git.pm, but when I tried it in git-svn.perl, it fails with the error "Can't locate object method 'value' via package 'Git::SVN'".
Show 10 quoted lines
> 
> A more standard approach in Perl is just:
> 
> 	eval {
> 		# something that will die
> 	};
> 	if ($@) {
> 		# error handling
> 	}
> 
Presumably $@ contains the Git::Error::Command object, which leaves me in the same spot, unfortunately.
> But yes, it is Perl after all and TMTOWTDI :)
Is there ever :)
-Andrew
Previous: Eric WongNext: Eric Wong
Message 3 of 7 in “git-svn: handling merge-base failures”
  1. Andrew MyrickDec 23, 2009
  2. Eric WongDec 23, 2009
  3. Andrew MyrickDec 23, 2009
  4. Eric WongDec 23, 2009
  5. Andrew MyrickJan 4, 2010
  6. Eric WongJan 4, 2010
  7. Andrew MyrickJan 4, 2010

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.