Skip to contentSkip to conversation

"Fast-"track Git GUI changes

PATCH In review Johannes Schindelin 2 participants 8 messages Jan 9, 2018 – Jan 10, 2018

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 git gui: fix staging a second line to a 1-line file

In reply to Johannes Schindelin

When a 1-line file is augmented by a second line, and the user tries to stage that single line via the "Stage Line" context menu item, we do not want to see "apply: corrupt patch at line 5".

The reason for this error was that the hunk header looks like this:

	@@ -1 +1,2 @@

but the existing code expects the original range always to contain a comma. This problem is easily fixed by cutting the string "1 +1,2" (that Git GUI formerly mistook for the starting line) at the space.

This fixes https://github.com/git-for-windows/git/issues/515

---
 git-gui/lib/diff.tcl | 1 +
 1 file changed, 1 insertion(+)
git-gui/lib/diff.tcl +1 -0
index 4cae10a4c7f..68c4a6c7366 100644
@@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {
 		set hh [$ui_diff get $i_l "$i_l + 1 lines"]
 		set hh [lindex [split $hh ,] 0]
 		set hln [lindex [split $hh -] 1]
+		set hln [lindex [split $hln " "] 0]
 
 		# There is a special situation to take care of. Consider this
 		# hunk:
Signature · 1 line
2.15.1.windows.2.395.g5bb0817ee52
#2 lore raw

PATCH 2/4 git-gui: avoid exception upon Ctrl+T in an empty list

In reply to Johannes Schindelin

Previously unstaged files can be staged by clicking on them and then pressing Ctrl+T. Conveniently, the next unstaged file is selected automatically so that the unstaged files can be staged by repeatedly pressing Ctrl+T.

When a user hits Ctrl+T one time too many, though, Git GUI used to throw this exception:

expected number but got ""
expected number but got ""
while executing
"expr {int([lindex [$w tag ranges in_diff] 0])}"
(procedure "toggle_or_diff" line 13) invoked from within
"toggle_or_diff toggle .vpane.files.workdir.list "
(command bound to event)

Let's just avoid that by skipping the operation when there are no more files to stage.

This fixes https://github.com/git-for-windows/git/issues/1060

---
 git-gui/git-gui.sh | 4 ++++
 1 file changed, 4 insertions(+)
git-gui/git-gui.sh +4 -0
index ed24aa9d2f1..3c085cddc61 100755
@@ -2504,6 +2504,10 @@ proc toggle_or_diff {mode w args} {
 		if {$last_clicked ne {}} {
 			set lno [lindex $last_clicked 1]
 		} else {
+			if {[llength $file_lists($w)] == 0} {
+				set last_clicked {}
+				return
+			}
 			set lno [expr {int([lindex [$w tag ranges in_diff] 0])}]
 		}
 		if {$mode eq "toggle"} {
Signature · 1 line
2.15.1.windows.2.395.g5bb0817ee52
#3 lore raw

PATCH 3/4 git-gui: fix exception when trying to stage with empty file list

In reply to Johannes Schindelin

If there is nothing to stage, there is nothing to stage. Let's not try to, even if the file list contains nothing at all.

This fixes https://github.com/git-for-windows/git/issues/1075

---
 git-gui/git-gui.sh | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
git-gui/git-gui.sh +10 -2
index 3c085cddc61..ca2cdebdc4f 100755
@@ -2504,7 +2504,9 @@ proc toggle_or_diff {mode w args} {
 		if {$last_clicked ne {}} {
 			set lno [lindex $last_clicked 1]
 		} else {
-			if {[llength $file_lists($w)] == 0} {
+			if {![info exists file_lists]
+				|| ![info exists file_lists($w)]
+				|| [llength $file_lists($w)] == 0} {
 				set last_clicked {}
 				return
 			}
@@ -2518,7 +2520,13 @@ proc toggle_or_diff {mode w args} {
 		}
 	}
 
-	set path [lindex $file_lists($w) [expr {$lno - 1}]]
+	if {![info exists file_lists]
+		|| ![info exists file_lists($w)]
+		|| [llength $file_lists($w)] < $lno - 1} {
+		set path {}
+	} else {
+		set path [lindex $file_lists($w) [expr {$lno - 1}]]
+	}
 	if {$path eq {}} {
 		set last_clicked {}
 		return
Signature · 1 line
2.15.1.windows.2.395.g5bb0817ee52
#4 lore raw

PATCH 4/4 git-gui: allow Ctrl+T to toggle multiple paths

In reply to Johannes Schindelin

It is possible to select multiple files in the "Unstaged Changes" and the "Staged Changes" lists. But when hitting Ctrl+T, surprisingly only one entry is handled, not all selected ones.

Let's just use the same code path as for the "Stage To Commit" and the "Unstage From Commit" menu items.

This fixes https://github.com/git-for-windows/git/issues/1012

---
 git-gui/git-gui.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
git-gui/git-gui.sh +13 -0
index ca2cdebdc4f..91c00e64893 100755
@@ -2501,6 +2501,19 @@ proc toggle_or_diff {mode w args} {
 		set pos [split [$w index @$x,$y] .]
 		foreach {lno col} $pos break
 	} else {
+		if {$mode eq "toggle"} {
+			if {$w eq $ui_workdir} {
+				do_add_selection
+				set last_clicked {}
+				return
+			}
+			if {$w eq $ui_index} {
+				do_unstage_selection
+				set last_clicked {}
+				return
+			}
+		}
+
 		if {$last_clicked ne {}} {
 			set lno [lindex $last_clicked 1]
 		} else {
Signature · 1 line
2.15.1.windows.2.395.g5bb0817ee52
#0 lore raw

cover "Fast-"track Git GUI changes

As it seems to be impossible to get the attention of the Git GUI maintainer these "days" (I have opened Pull Requests on October 16th 2016 that have not even been looked at), let's just side-step that contribution path which seems to be dormant.

These fixes have been in Git for Windows for various amounts of time.

Note: there are more Git GUI changes in Git for Windows, I only accumulated the ones I deem wort considering for inclusion into v2.16.0, still.

Johannes Schindelin (4):
git gui: fix staging a second line to a 1-line file
git-gui: avoid exception upon Ctrl+T in an empty list
git-gui: fix exception when trying to stage with empty file list
git-gui: allow Ctrl+T to toggle multiple paths

 git-gui/git-gui.sh   | 27 ++++++++++++++++++++++++++-
 git-gui/lib/diff.tcl |  1 +
 2 files changed, 27 insertions(+), 1 deletion(-)

base-commit: 36438dc19dd2a305dddebd44bf7a65f1a220075b
Published-As: https://github.com/dscho/git/releases/tag/misc-git-gui-stuff-v1
Fetch-It-Via: git fetch https://github.com/dscho/git misc-git-gui-stuff-v1

Signature · 1 line
2.15.1.windows.2.395.g5bb0817ee52
#5 lore raw
Quoted 4 lines · Johannes Schindelin

As it seems to be impossible to get the attention of the Git GUI maintainer these "days" (I have opened Pull Requests on October 16th 2016 that have not even been looked at), let's just side-step that contribution path which seems to be dormant.

Good to see that finally somebody else steps up after I did the same for a few times recently.

Quoted 5 lines

These fixes have been in Git for Windows for various amounts of time.

Note: there are more Git GUI changes in Git for Windows, I only accumulated the ones I deem wort considering for inclusion into v2.16.0, still.

Thanks. I am not sure if it is too late for 2.16, as these are not fixes for regression during this cycle, though.

#6 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 4 lines · Johannes Schindelin

As it seems to be impossible to get the attention of the Git GUI maintainer these "days" (I have opened Pull Requests on October 16th 2016 that have not even been looked at), let's just side-step that contribution path which seems to be dormant.

Good to see that finally somebody else steps up after I did the same for a few times recently.

Quoted 8 lines
Quoted 5 lines

These fixes have been in Git for Windows for various amounts of time.

Note: there are more Git GUI changes in Git for Windows, I only accumulated the ones I deem wort considering for inclusion into v2.16.0, still.

Thanks. I am not sure if it is too late for 2.16, as these are not fixes for regression during this cycle, though.

Heh, I changed my mind.

Just like I pretended to be interim maintainer of Git-GUI for the past two times, you are doing the same this time and I even agreed that it was a good thing that you volunteered to pretend as one.

So let's follow through the pretence to its conclusion and merge these directly to 'master'.

Thanks.

#7 lore raw

Hi,

Quoted 21 lines · Junio C Hamano
Quoted 10 lines · Junio C Hamano
Quoted 4 lines · Johannes Schindelin

As it seems to be impossible to get the attention of the Git GUI maintainer these "days" (I have opened Pull Requests on October 16th 2016 that have not even been looked at), let's just side-step that contribution path which seems to be dormant.

Good to see that finally somebody else steps up after I did the same for a few times recently.

Quoted 8 lines
Quoted 5 lines

These fixes have been in Git for Windows for various amounts of time.

Note: there are more Git GUI changes in Git for Windows, I only accumulated the ones I deem wort considering for inclusion into v2.16.0, still.

Thanks. I am not sure if it is too late for 2.16, as these are not fixes for regression during this cycle, though.

Quoted 8 lines

Heh, I changed my mind.

Just like I pretended to be interim maintainer of Git-GUI for the past two times, you are doing the same this time and I even agreed that it was a good thing that you volunteered to pretend as one.

So let's follow through the pretence to its conclusion and merge these directly to 'master'.

Thank you, fellow pretender.

Ciao,
Dscho