Server IP : 103.119.228.120 / Your IP : 18.116.15.22 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/git-1.8.3.1/contrib/blameview/ |
Upload File : |
#!/usr/bin/perl use Gtk2 -init; use Gtk2::SimpleList; my $hash; my $fn; if ( @ARGV == 1 ) { $hash = "HEAD"; $fn = shift; } elsif ( @ARGV == 2 ) { $hash = shift; $fn = shift; } else { die "Usage blameview [<rev>] <filename>"; } Gtk2::Rc->parse_string(<<'EOS'); style "treeview_style" { GtkTreeView::vertical-separator = 0 } class "GtkTreeView" style "treeview_style" EOS my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(destroy => sub { Gtk2->main_quit }); my $vpan = Gtk2::VPaned->new(); $window->add($vpan); my $scrolled_window = Gtk2::ScrolledWindow->new; $vpan->pack1($scrolled_window, 1, 1); my $fileview = Gtk2::SimpleList->new( 'Commit' => 'text', 'FileLine' => 'text', 'Data' => 'text' ); $scrolled_window->add($fileview); $fileview->get_column(0)->set_spacing(0); $fileview->set_size_request(1024, 768); $fileview->set_rules_hint(1); $fileview->signal_connect (row_activated => sub { my ($sl, $path, $column) = @_; my $row_ref = $sl->get_row_data_from_path ($path); system("blameview @$row_ref[0]~1 $fn &"); }); my $commitwindow = Gtk2::ScrolledWindow->new(); $commitwindow->set_policy ('GTK_POLICY_AUTOMATIC','GTK_POLICY_AUTOMATIC'); $vpan->pack2($commitwindow, 1, 1); my $commit_text = Gtk2::TextView->new(); my $commit_buffer = Gtk2::TextBuffer->new(); $commit_text->set_buffer($commit_buffer); $commitwindow->add($commit_text); $fileview->signal_connect (cursor_changed => sub { my ($sl) = @_; my ($path, $focus_column) = $sl->get_cursor(); my $row_ref = $sl->get_row_data_from_path ($path); my $c_fh; open($c_fh, '-|', "git cat-file commit @$row_ref[0]") or die "unable to find commit @$row_ref[0]"; my @buffer = <$c_fh>; $commit_buffer->set_text("@buffer"); close($c_fh); }); my $fh; open($fh, '-|', "git cat-file blob $hash:$fn") or die "unable to open $fn: $!"; while(<$fh>) { chomp; $fileview->{data}->[$.] = ['HEAD', "$fn:$.", $_]; } my $blame; open($blame, '-|', qw(git blame --incremental --), $fn, $hash) or die "cannot start git-blame $fn"; Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line); $window->show_all; Gtk2->main; exit 0; my %commitinfo = (); sub flush_blame_line { my ($attr) = @_; return unless defined $attr; my ($commit, $s_lno, $lno, $cnt) = @{$attr}{qw(COMMIT S_LNO LNO CNT)}; my ($filename, $author, $author_time, $author_tz) = @{$commitinfo{$commit}}{qw(FILENAME AUTHOR AUTHOR-TIME AUTHOR-TZ)}; my $info = $author . ' ' . format_time($author_time, $author_tz); for(my $i = 0; $i < $cnt; $i++) { @{$fileview->{data}->[$lno+$i-1]}[0,1,2] = (substr($commit, 0, 8), $filename . ':' . ($s_lno+$i)); } } my $buf; my $current; sub read_blame_line { my $r = sysread($blame, $buf, 1024, length($buf)); die "I/O error" unless defined $r; if ($r == 0) { flush_blame_line($current); $current = undef; return 0; } while ($buf =~ s/([^\n]*)\n//) { my $line = $1; if (($commit, $s_lno, $lno, $cnt) = ($line =~ /^([0-9a-f]{40}) (\d+) (\d+) (\d+)$/)) { flush_blame_line($current); $current = +{ COMMIT => $1, S_LNO => $2, LNO => $3, CNT => $4, }; next; } # extended attribute values if ($line =~ /^(author|author-mail|author-time|author-tz|committer|committer-mail|committer-time|committer-tz|summary|filename) (.*)$/) { my $commit = $current->{COMMIT}; $commitinfo{$commit}{uc($1)} = $2; next; } } return 1; } sub format_time { my $time = shift; my $tz = shift; my $minutes = $tz < 0 ? 0-$tz : $tz; $minutes = ($minutes / 100)*60 + ($minutes % 100); $minutes = $tz < 0 ? 0-$minutes : $minutes; $time += $minutes * 60; my @t = gmtime($time); return sprintf('%04d-%02d-%02d %02d:%02d:%02d %s', $t[5] + 1900, @t[4,3,2,1,0], $tz); }