1 # git-gui object database management support
2 # Copyright (C) 2006, 2007 Shawn Pearce
6 set fd
[git_read count-objects
-v]
7 while {[gets $fd line
] > 0} {
8 if {[regexp {^
([^
:]+): (\d
+)$} $line _ name value
]} {
9 set stats
($name) $value
15 foreach p
[glob -directory [gitdir objects
pack] \
18 incr packed_sz
[file size
$p]
21 set stats
(size-pack
) [expr {$packed_sz / 1024}]
27 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
29 ${NS
}::frame $w.buttons
30 ${NS
}::button $w.buttons.
close -text [mc Close
] \
32 -command [list destroy $w]
33 ${NS
}::button $w.buttons.gc
-text [mc
"Compress Database"] \
35 -command "destroy $w;do_gc"
36 pack $w.buttons.
close -side right
37 pack $w.buttons.gc
-side left
38 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
40 ${NS
}::labelframe $w.stat
-text [mc
"Database Statistics"]
42 {count
{mc
"Number of loose objects"}}
43 {size
{mc
"Disk space used by loose objects"} { KiB
}}
44 {in-pack
{mc
"Number of packed objects"}}
45 {packs
{mc
"Number of packs"}}
46 {size-pack
{mc
"Disk space used by packed objects"} { KiB
}}
47 {prune-packable
{mc
"Packed objects waiting for pruning"}}
48 {garbage
{mc
"Garbage files"}}
50 set name
[lindex $s 0]
51 set label [eval [lindex $s 1]]
52 if {[catch {set value
$stats($name)}]} continue
53 if {[llength $s] > 2} {
54 set value
"$value[lindex $s 2]"
57 ${NS
}::label $w.stat.l_
$name -text [mc
"%s:" $label] -anchor w
58 ${NS
}::label $w.stat.v_
$name -text $value -anchor w
59 grid $w.stat.l_
$name $w.stat.v_
$name -sticky we
-padx {0 5}
61 pack $w.stat
-pady 10 -padx 10
63 bind $w <Visibility
> "grab $w; focus $w.buttons.close"
64 bind $w <Key-Escape
> [list destroy $w]
65 bind $w <Key-Return
> [list destroy $w]
66 wm title
$w [append "[appname] ([reponame]): " [mc
"Database Statistics"]]
72 set w
[console::new {gc
} [mc
"Compressing the object database"]]
74 {exec git pack-refs
--prune}
75 {exec git reflog expire
--all}
76 {exec git repack
-a -d -l}
81 proc do_fsck_objects
{} {
82 set w
[console::new {fsck-objects
} \
83 [mc
"Verifying the object database with fsck-objects"]]
84 set cmd
[list git fsck-objects
]
99 set count
[llength [glob \
102 [gitdir objects
4\[0-[expr {$ndirs-1}]\]/*]]]
104 if {$count >= $limit * $ndirs} {
105 set objects_current
[expr {$count * 256/$ndirs}]
107 [mc
"This repository currently has approximately %i loose objects.
109 To maintain optimal performance it is strongly recommended that you compress the database.
111 Compress the database now?" $objects_current]] eq yes
} {