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>
Jakub Narebski committed
Jul 28, 2007 at 16:27 UTC
01ac1e38dbb1ae3ad3c4bbea60a9c0855606ae11
1 file changed
+35
-3
gitweb/gitweb.perl
+35
-3
@@ -890,11 +890,25 @@ sub age_string {
890
return $age_str;
891
}
892
893
+use constant {
894
+ S_IFINVALID => 0030000,
895
+ S_IFGITLINK => 0160000,
896
+};
897
+
898
+# submodule/subproject, a commit object reference
899
+sub S_ISGITLINK($) {
900
+ my $mode = shift;
901
+
902
+ return (($mode & S_IFMT) == S_IFGITLINK)
903
+}
904
+
905
# convert file mode in octal to symbolic file mode string
906
sub mode_str {
907
my $mode = oct shift;
908
897
- if (S_ISDIR($mode & S_IFMT)) {
909
+ if (S_ISGITLINK($mode)) {
910
+ return 'm---------';
911
+ } elsif (S_ISDIR($mode & S_IFMT)) {
912
return 'drwxr-xr-x';
913
} elsif (S_ISLNK($mode)) {
914
return 'lrwxrwxrwx';
@@ -920,7 +934,9 @@ sub file_type {
934
$mode = oct $mode;
935
}
936
923
- if (S_ISDIR($mode & S_IFMT)) {
937
+ if (S_ISGITLINK($mode)) {
938
+ return "submodule";
939
+ } elsif (S_ISDIR($mode & S_IFMT)) {
940
return "directory";
941
} elsif (S_ISLNK($mode)) {
942
return "symlink";
@@ -941,7 +957,9 @@ sub file_type_long {
957
$mode = oct $mode;
958
}
959
944
- if (S_ISDIR($mode & S_IFMT)) {
960
+ if (S_ISGITLINK($mode)) {
961
+ return "submodule";
962
+ } elsif (S_ISDIR($mode & S_IFMT)) {
963
return "directory";
964
} elsif (S_ISLNK($mode)) {
965
return "symlink";
@@ -2707,6 +2725,20 @@ sub git_print_tree_entry {
2725
"history");
2726
}
2727
print "</td>\n";
2728
+ } else {
2729
+ # unknown object: we can only present history for it
2730
+ # (this includes 'commit' object, i.e. submodule support)
2731
+ print "<td class=\"list\">" .
2732
+ esc_path($t->{'name'}) .
2733
+ "</td>\n";
2734
+ print "<td class=\"link\">";
2735
+ if (defined $hash_base) {
2736
+ print $cgi->a({-href => href(action=>"history",
2737
+ hash_base=>$hash_base,
2738
+ file_name=>"$basedir$t->{'name'}")},
2739
+ "history");
2740
+ }
2741
+ print "</td>\n";
2742
}
2743
}
2744