Skip to content

Commit

Permalink
Merge git://repo.or.cz/git-gui
Browse files Browse the repository at this point in the history
* git://repo.or.cz/git-gui:
  git-gui: adjust the minimum height of diff pane for shorter screen height
  git-gui: fix use of uninitialized variable
  git-gui: store wm state and fix wm geometry
  git-gui: Ensure submodule path is quoted properly
  git-gui: fix diff for partially staged submodule changes
  git-gui: Update russian translation
  git-gui: Limit display to a maximum number of files
  git-gui: remove warning when deleting correctly merged remote branch
  git-gui: Added Greek translation & glossary
  git-gui: display summary when showing diff of a submodule
  • Loading branch information
Junio C Hamano committed Oct 27, 2009
2 parents 610f99e + acb9108 commit 4096958
Show file tree
Hide file tree
Showing 7 changed files with 2,276 additions and 24 deletions.
43 changes: 40 additions & 3 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ set default_config(gui.newbranchtemplate) {}
set default_config(gui.spellingdictionary) {}
set default_config(gui.fontui) [font configure font_ui]
set default_config(gui.fontdiff) [font configure font_diff]
# TODO: this option should be added to the git-config documentation
set default_config(gui.maxfilesdisplayed) 5000
set font_descs {
{fontui font_ui {mc "Main Font"}}
{fontdiff font_diff {mc "Diff/Console Font"}}
Expand Down Expand Up @@ -1132,6 +1134,7 @@ set current_branch {}
set is_detached 0
set current_diff_path {}
set is_3way_diff 0
set is_submodule_diff 0
set is_conflict_diff 0
set selected_commit_type new
set diff_empty_count 0
Expand Down Expand Up @@ -1698,10 +1701,12 @@ proc display_all_files_helper {w path icon_name m} {
$w insert end "[escape_path $path]\n"
}
set files_warning 0
proc display_all_files {} {
global ui_index ui_workdir
global file_states file_lists
global last_clicked
global files_warning
$ui_index conf -state normal
$ui_workdir conf -state normal
Expand All @@ -1713,7 +1718,18 @@ proc display_all_files {} {
set file_lists($ui_index) [list]
set file_lists($ui_workdir) [list]
foreach path [lsort [array names file_states]] {
set to_display [lsort [array names file_states]]
set display_limit [get_config gui.maxfilesdisplayed]
if {[llength $to_display] > $display_limit} {
if {!$files_warning} {
# do not repeatedly warn:
set files_warning 1
info_popup [mc "Displaying only %s of %s files." \
$display_limit [llength $to_display]]
}
set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
}
foreach path $to_display {
set s $file_states($path)
set m [lindex $s 0]
set icon_name [lindex $s 1]
Expand Down Expand Up @@ -2010,6 +2026,19 @@ proc do_quit {{rc {1}}} {
# -- Stash our current window geometry into this repository.
#
set cfg_wmstate [wm state .]
if {[catch {set rc_wmstate $repo_config(gui.wmstate)}]} {
set rc_wmstate {}
}
if {$cfg_wmstate ne $rc_wmstate} {
catch {git config gui.wmstate $cfg_wmstate}
}
if {$cfg_wmstate eq {zoomed}} {
# on Windows wm geometry will lie about window
# position (but not size) when window is zoomed
# restore the window before querying wm geometry
wm state . normal
}
set cfg_geometry [list]
lappend cfg_geometry [wm geometry .]
lappend cfg_geometry [lindex [.vpane sash coord 0] 0]
Expand Down Expand Up @@ -3054,7 +3083,7 @@ frame .vpane.lower.diff.body
set ui_diff .vpane.lower.diff.body.t
text $ui_diff -background white -foreground black \
-borderwidth 0 \
-width 80 -height 15 -wrap none \
-width 80 -height 5 -wrap none \
-font font_diff \
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
-yscrollcommand {.vpane.lower.diff.body.sby set} \
Expand Down Expand Up @@ -3212,7 +3241,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
set l [mc "Stage Hunk For Commit"]
set t [mc "Stage Line For Commit"]
}
if {$::is_3way_diff
if {$::is_3way_diff || $::is_submodule_diff
|| $current_diff_path eq {}
|| {__} eq $state
|| {_O} eq $state
Expand Down Expand Up @@ -3249,6 +3278,14 @@ wm geometry . [lindex $gm 0]
unset gm
}
# -- Load window state
#
catch {
set gws $repo_config(gui.wmstate)
wm state . $gws
unset gws
}
# -- Key Bindings
#
bind $ui_comm <$M1B-Key-Return> {do_commit;break}
Expand Down
32 changes: 30 additions & 2 deletions git-gui/lib/diff.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} {

proc start_show_diff {cont_info {add_opts {}}} {
global file_states file_lists
global is_3way_diff diff_active repo_config
global is_3way_diff is_submodule_diff diff_active repo_config
global ui_diff ui_index ui_workdir
global current_diff_path current_diff_side current_diff_header

Expand All @@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
set s $file_states($path)
set m [lindex $s 0]
set is_3way_diff 0
set is_submodule_diff 0
set diff_active 1
set current_diff_header {}

Expand Down Expand Up @@ -295,6 +296,16 @@ proc start_show_diff {cont_info {add_opts {}}} {
lappend cmd $path
}

if {[string match {160000 *} [lindex $s 2]]
|| [string match {160000 *} [lindex $s 3]]} {
set is_submodule_diff 1
if {$w eq $ui_index} {
set cmd [list submodule summary --cached -- $path]
} else {
set cmd [list submodule summary --files -- $path]
}
}

if {[catch {set fd [eval git_read --nice $cmd]} err]} {
set diff_active 0
unlock_index
Expand All @@ -312,7 +323,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
}

proc read_diff {fd cont_info} {
global ui_diff diff_active
global ui_diff diff_active is_submodule_diff
global is_3way_diff is_conflict_diff current_diff_header
global current_diff_queue
global diff_empty_count
Expand Down Expand Up @@ -374,6 +385,23 @@ proc read_diff {fd cont_info} {
set tags {}
}
}
} elseif {$is_submodule_diff} {
if {$line == ""} continue
if {[regexp {^\* } $line]} {
set line [string replace $line 0 1 {Submodule }]
set tags d_@
} else {
set op [string range $line 0 2]
switch -- $op {
{ <} {set tags d_-}
{ >} {set tags d_+}
{ W} {set tags {}}
default {
puts "error: Unhandled submodule diff marker: {$op}"
set tags {}
}
}
}
} else {
set op [string index $line 0]
switch -- $op {
Expand Down
16 changes: 9 additions & 7 deletions git-gui/lib/remote_branch_delete.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ method _delete {} {
return
}

if {[tk_messageBox \
-icon warning \
-type yesno \
-title [wm title $w] \
-parent $w \
-message [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]] ne yes} {
return
if {$checktype ne {head}} {
if {[tk_messageBox \
-icon warning \
-type yesno \
-title [wm title $w] \
-parent $w \
-message [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]] ne yes} {
return
}
}

destroy $w
Expand Down
Loading

0 comments on commit 4096958

Please sign in to comment.