Skip to content

Commit 974fdd3

Browse files
committed
Merge branch 'j6t-testing' of https://github.com/j6t/git-gui
2 parents 9085ccd + f896dc7 commit 974fdd3

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

git-gui/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ page](https://git-scm.com/docs/git-gui).
1111
Git GUI was initially written by Shawn O. Pearce, and is distributed with the
1212
standard Git installation.
1313

14+
Examples of `git gui blame` and `git citool`, the most popular tools in the git-gui
15+
suite:
16+
17+
![git gui blame example](docs/git-gui-blame-example.png)
18+
19+
![git citool example](docs/git-citool-example.png)
20+
1421
# Building and installing
1522

1623
You need to have the following dependencies installed before you begin:
88 KB
Loading
157 KB
Loading

git-gui/git-gui.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ set font_descs {
868868
}
869869
set default_config(gui.stageuntracked) ask
870870
set default_config(gui.displayuntracked) true
871+
set default_config(gui.autorescan) true
871872

872873
######################################################################
873874
##
@@ -1934,6 +1935,7 @@ set all_icons(U$ui_index) file_merge
19341935
set all_icons(T$ui_index) file_statechange
19351936

19361937
set all_icons(_$ui_workdir) file_plain
1938+
set all_icons(A$ui_workdir) file_plain
19371939
set all_icons(M$ui_workdir) file_mod
19381940
set all_icons(D$ui_workdir) file_question
19391941
set all_icons(U$ui_workdir) file_merge
@@ -1960,6 +1962,7 @@ foreach i {
19601962
{A_ {mc "Staged for commit"}}
19611963
{AM {mc "Portions staged for commit"}}
19621964
{AD {mc "Staged for commit, missing"}}
1965+
{AA {mc "Intended to be added"}}
19631966

19641967
{_D {mc "Missing"}}
19651968
{D_ {mc "Staged for removal"}}
@@ -3111,7 +3114,7 @@ pack .vpane -anchor n -side top -fill both -expand 1
31113114

31123115
# -- Working Directory File List
31133116

3114-
textframe .vpane.files.workdir -height 100 -width 200
3117+
textframe .vpane.files.workdir -height 300 -width 400
31153118
tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
31163119
-background lightsalmon -foreground black
31173120
ttext $ui_workdir \
@@ -3132,7 +3135,7 @@ pack $ui_workdir -side left -fill both -expand 1
31323135

31333136
# -- Index File List
31343137
#
3135-
textframe .vpane.files.index -height 100 -width 200
3138+
textframe .vpane.files.index -height 300 -width 400
31363139
tlabel .vpane.files.index.title \
31373140
-text [mc "Staged Changes (Will Commit)"] \
31383141
-background lightgreen -foreground black
@@ -3823,6 +3826,10 @@ bind . <Alt-Key-2> {focus_widget $::ui_index}
38233826
bind . <Alt-Key-3> {focus $::ui_diff}
38243827
bind . <Alt-Key-4> {focus $::ui_comm}
38253828

3829+
if {[is_config_true gui.autorescan]} {
3830+
bind . <FocusIn> { if {"%W" eq "."} { after idle do_rescan } }
3831+
}
3832+
38263833
set file_lists_last_clicked($ui_index) {}
38273834
set file_lists_last_clicked($ui_workdir) {}
38283835

git-gui/lib/diff.tcl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ proc apply_or_revert_hunk {x y revert} {
554554
if {$current_diff_side eq $ui_index} {
555555
set failed_msg [mc "Failed to unstage selected hunk."]
556556
lappend apply_cmd --reverse --cached
557-
if {[string index $mi 0] ne {M}} {
557+
set file_state [string index $mi 0]
558+
if {$file_state ne {M} && $file_state ne {A}} {
558559
unlock_index
559560
return
560561
}
@@ -567,7 +568,8 @@ proc apply_or_revert_hunk {x y revert} {
567568
lappend apply_cmd --cached
568569
}
569570

570-
if {[string index $mi 1] ne {M}} {
571+
set file_state [string index $mi 1]
572+
if {$file_state ne {M} && $file_state ne {A}} {
571573
unlock_index
572574
return
573575
}
@@ -648,7 +650,13 @@ proc apply_or_revert_range_or_line {x y revert} {
648650
}
649651

650652
set first_l [$ui_diff index "$first linestart"]
651-
set last_l [$ui_diff index "$last lineend"]
653+
# don't include the next line if $last points to the start of a line
654+
# ie. <lno>.0
655+
if {[lindex [split $last .] 1] == 0} {
656+
set last_l [$ui_diff index "$last -1 line lineend"]
657+
} else {
658+
set last_l [$ui_diff index "$last lineend"]
659+
}
652660

653661
if {$current_diff_path eq {} || $current_diff_header eq {}} return
654662
if {![lock_index apply_hunk]} return
@@ -659,7 +667,8 @@ proc apply_or_revert_range_or_line {x y revert} {
659667
set failed_msg [mc "Failed to unstage selected line."]
660668
set to_context {+}
661669
lappend apply_cmd --reverse --cached
662-
if {[string index $mi 0] ne {M}} {
670+
set file_state [string index $mi 0]
671+
if {$file_state ne {M} && $file_state ne {A}} {
663672
unlock_index
664673
return
665674
}
@@ -674,7 +683,8 @@ proc apply_or_revert_range_or_line {x y revert} {
674683
lappend apply_cmd --cached
675684
}
676685

677-
if {[string index $mi 1] ne {M}} {
686+
set file_state [string index $mi 1]
687+
if {$file_state ne {M} && $file_state ne {A}} {
678688
unlock_index
679689
return
680690
}

git-gui/lib/option.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ proc do_options {} {
145145
{b merge.diffstat {mc "Show Diffstat After Merge"}}
146146
{t merge.tool {mc "Use Merge Tool"}}
147147

148+
{b gui.autorescan {mc "Auto-Rescan On Activate"}}
148149
{b gui.trustmtime {mc "Trust File Modification Timestamps"}}
149150
{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
150151
{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
@@ -332,6 +333,7 @@ proc do_save_config {w} {
332333
if {[catch {save_config} err]} {
333334
error_popup [strcat [mc "Failed to completely save options:"] "\n\n$err"]
334335
}
336+
load_config 1
335337
reshow_diff
336338
destroy $w
337339
}

0 commit comments

Comments
 (0)