gitweb: Show submodule entries in the 'tree' view
Add S_ISGITLINK subroutine and S_IFGITLINK, S_IFINVALID constants.
Add support for "commit" (submodule) entries in the tree object to
mode_str ('m---------', following cgit), file_type and file_type_long
('submodule') subroutines.
There is only link to the history of submodule entry in the
supermodule (current repository) for now, because gitweb doesn't know
where to search for submodule repository objects.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
			
			
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							90ae710e0b
						
					
				
				
					commit
					01ac1e38db
				
			@ -890,11 +890,25 @@ sub age_string {
 | 
			
		||||
	return $age_str;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
use constant {
 | 
			
		||||
	S_IFINVALID => 0030000,
 | 
			
		||||
	S_IFGITLINK => 0160000,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
# submodule/subproject, a commit object reference
 | 
			
		||||
sub S_ISGITLINK($) {
 | 
			
		||||
	my $mode = shift;
 | 
			
		||||
 | 
			
		||||
	return (($mode & S_IFMT) == S_IFGITLINK)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# convert file mode in octal to symbolic file mode string
 | 
			
		||||
sub mode_str {
 | 
			
		||||
	my $mode = oct shift;
 | 
			
		||||
 | 
			
		||||
	if (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
	if (S_ISGITLINK($mode)) {
 | 
			
		||||
		return 'm---------';
 | 
			
		||||
	} elsif (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
		return 'drwxr-xr-x';
 | 
			
		||||
	} elsif (S_ISLNK($mode)) {
 | 
			
		||||
		return 'lrwxrwxrwx';
 | 
			
		||||
@ -920,7 +934,9 @@ sub file_type {
 | 
			
		||||
		$mode = oct $mode;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
	if (S_ISGITLINK($mode)) {
 | 
			
		||||
		return "submodule";
 | 
			
		||||
	} elsif (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
		return "directory";
 | 
			
		||||
	} elsif (S_ISLNK($mode)) {
 | 
			
		||||
		return "symlink";
 | 
			
		||||
@ -941,7 +957,9 @@ sub file_type_long {
 | 
			
		||||
		$mode = oct $mode;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
	if (S_ISGITLINK($mode)) {
 | 
			
		||||
		return "submodule";
 | 
			
		||||
	} elsif (S_ISDIR($mode & S_IFMT)) {
 | 
			
		||||
		return "directory";
 | 
			
		||||
	} elsif (S_ISLNK($mode)) {
 | 
			
		||||
		return "symlink";
 | 
			
		||||
@ -2707,6 +2725,20 @@ sub git_print_tree_entry {
 | 
			
		||||
			              "history");
 | 
			
		||||
		}
 | 
			
		||||
		print "</td>\n";
 | 
			
		||||
	} else {
 | 
			
		||||
		# unknown object: we can only present history for it
 | 
			
		||||
		# (this includes 'commit' object, i.e. submodule support)
 | 
			
		||||
		print "<td class=\"list\">" .
 | 
			
		||||
		      esc_path($t->{'name'}) .
 | 
			
		||||
		      "</td>\n";
 | 
			
		||||
		print "<td class=\"link\">";
 | 
			
		||||
		if (defined $hash_base) {
 | 
			
		||||
			print $cgi->a({-href => href(action=>"history",
 | 
			
		||||
			                             hash_base=>$hash_base,
 | 
			
		||||
			                             file_name=>"$basedir$t->{'name'}")},
 | 
			
		||||
			              "history");
 | 
			
		||||
		}
 | 
			
		||||
		print "</td>\n";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user