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

[PATCH] import-tars: Use the "Link indicator" to identify directories

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 16, 2007, 16:22 UTC
Message-ID
<Pine.LNX.4.64.0705161659530.6410@racer.site>
In-Reply-To
<6efbd9b70705111308v47a76b04n9328ebf393a209e6@mail.gmail.com>

Earlier, we used the mode to determine if a name was associated with a directory. This fails, since some tar programs do not set the mode correctly. However, the link indicator _has_ to be set correctly.

Noticed by Chris Riddoch.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Fri, 11 May 2007, Chris Riddoch wrote:
	> I believe I've uncovered an issue in fast-import, but I don't 
	> know the code well enough yet to debug it.  So, I'll produce my 
	> evidence and let others work on finding the solution.  It should 
	> be pretty easy to reproduce.
	It was easy. Thanks.
	The problem is -- again -- that a directory is overwritten, since 
	it is not recognized as a directory. Earlier, I tried to use the 
	trailing "/" for that. Which fails with your example.
	I actually took the time to research in Wikipedia what should be 
	the correct way to find out if the current item is a directory...
 contrib/fast-import/import-tars.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 1e6fa5a..23aeb25 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -75,7 +75,7 @@ foreach my $tar_file (@ARGV)
 		$mode = oct $mode;
 		$size = oct $size;
 		$mtime = oct $mtime;
-		next if $mode & 0040000;
+		next if $typeflag == 5; # directory
 
 		print FI "blob\n", "mark :$next_mark\n", "data $size\n";
 		while ($size > 0 && read(I, $_, 512) == 512) {
-- 
1.5.2.rc3.2506.ge455
Previous: Chris RiddochNext: Junio C Hamano
Message 2 of 4 in “Another fast-import/import-tars issue”
  1. Chris RiddochMay 11, 2007
  2. import-tars: Use the "Link indicator" to identify directoriesJohannes Schindelin, May 16, 2007
  3. Junio C HamanoMay 16, 2007
  4. Junio C HamanoMay 16, 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.