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

Re: [PATCH 2/3 v3] git-svn info: implement info command

From
EWEric Wong <normalperson@yhbt.net>
Date
Nov 22, 2007, 01:40 UTC
Message-ID
<20071122014038.GA25341@soma>
In-Reply-To
<1195675039-26746-3-git-send-email-ddkilzer@kilzer.net>
"David D. Kilzer" <ddkilzer@kilzer.net> wrote:
Show 5 quoted lines
> Implement "git-svn info" for files and directories based on the
> "svn info" command.  Note that the -r/--revision argument is not
> supported yet.
> 
> Added 18 tests in t/t9119-git-svn-info.sh.
Eric Wong <normalperson@yhbt.net> wrote:
Show 13 quoted lines
> I'm having a problem with [2/3] currently:
> 
> $file_type not being detected correctly when running "git svn info"
> on the top-level directory with no arguments.  It's opening the
> directory and trying to md5 it here:
> 
> 		} else {
> 			open FILE, "<", $path or die $!;
> 			$checksum = Git::SVN::Util::md5sum(\*FILE);
> 			close FILE or die $!;
> 		}
> 
>

When running from a top-level directory with no arguments, the first line of git-ls-tree was being read. This allowed the test case to pass because ls-tree sorts the output and 'directory' just happened to be up top; so we were getting the 040000 mode from the 'directory' tree and not the top-level tree.

The below test should fix it for the trivial case I have.
diff --git a/git-svn.perl b/git-svn.perl
index 62801c8..7d86870 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1165,6 +1165,7 @@ sub linearize_history {
 
 sub find_file_type_and_diff_status {
 	my ($path) = @_;
+	return ('dir', '') if $path eq '.';
 
 	my $diff_output =
 	    command_oneline(qw(diff --cached --name-status --), $path) || "";
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index e81457f..439bd93 100644
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -19,6 +19,7 @@ ptouch() {
 test_expect_success 'setup repository and import' "
 	mkdir info &&
 	cd info &&
+		echo FIRST > A &&
 		echo one > file &&
 		ln -s file symlink-file &&
 		mkdir directory &&
-- 
Eric Wong
Previous: David D. KilzerNext: David D. Kilzer
Message 5 of 11 in “Implement git-svn info”
  1. 0/3 Implement git-svn infoDavid D. Kilzer, Nov 21, 2007
  2. 1/3 git-svn: extract reusable code into utility functionsDavid D. Kilzer, Nov 21, 2007
  3. 2/3 git-svn info: implement info commandDavid D. Kilzer, Nov 21, 2007
  4. 3/3 git-svn: info --url [path]David D. Kilzer, Nov 21, 2007
  5. Eric WongNov 22, 2007
  6. David D. KilzerNov 22, 2007
  7. Eric WongNov 22, 2007
  8. Eric WongNov 22, 2007
  9. 4/3 git-svn: allow `info' command to work offlineEric Wong, Nov 22, 2007
  10. Adam RobenNov 22, 2007
  11. Eric WongNov 22, 2007

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.