Skip to contentSkip to conversation

git-gui: Reenable staging unmerged files by clicking the icon.

PATCH In review Alexander Gavrilov 3 participants 4 messages Jun 15, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-gui: Reenable staging unmerged files by clicking the icon.

This restores functionality of the file icon for unmerged files. Safety is enforced by loading the diff and checking for lines that look like conflict markers. If such lines are found, or the conflict involves deletion and/or symlinks, a confirmation dialog is presented. Otherwise, the icon immediately stages the working copy version of the file.

Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca (Restore ability to Stage Working Copy for conflicts)

---
 git-gui.sh        |   18 ++++++++----------
 lib/diff.tcl      |   52 +++++++++++++++++++++++++++++++++++-----------------
 lib/mergetool.tcl |   33 +++++++++++++++++++++++++++------
 3 files changed, 70 insertions(+), 33 deletions(-)
git-gui.sh +8 -10
index 3bbb4f1..9e5b122 100755
@@ -1059,6 +1059,7 @@ set current_branch {}
 set is_detached 0
 set current_diff_path {}
 set is_3way_diff 0
+set is_conflict_diff 0
 set selected_commit_type new
 
 set nullid "0000000000000000000000000000000000000000"
@@ -2013,19 +2014,21 @@ proc toggle_or_diff {w x y} {
 	$ui_index tag remove in_sel 0.0 end
 	$ui_workdir tag remove in_sel 0.0 end
 
-	# Do not stage files with conflicts
+	# Determine the state of the file
 	if {[info exists file_states($path)]} {
 		set state [lindex $file_states($path) 0]
 	} else {
 		set state {__}
 	}
 
-	if {[string first {U} $state] >= 0} {
-		set col 1
-	}
-
 	# Restage the file, or simply show the diff
 	if {$col == 0 && $y > 1} {
+		# Conflicts need special handling
+		if {[string first {U} $state] >= 0} {
+			merge_stage_workdir $path $w $lno
+			return
+		}
+
 		if {[string index $state 1] eq {O}} {
 			set mmask {}
 		} else {
@@ -2984,11 +2987,6 @@ $ctxmmg add command \
 	-command {merge_resolve_one 1}
 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
 $ctxmmg add separator
-$ctxmmg add command \
-	-label [mc "Stage Working Copy"] \
-	-command {merge_resolve_one 0}
-lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
-$ctxmmg add separator
 create_common_diff_popup $ctxmmg
 
 proc popup_diff_menu {ctxm ctxmmg x y X Y} {
lib/diff.tcl +35 -17

162 lines not on this page · raw message

lib/mergetool.tcl +27 -6
index dd2315b..9693e47 100644
@@ -5,12 +5,6 @@ proc merge_resolve_one {stage} {
 	global current_diff_path
 
 	switch -- $stage {
-		0 {	# Stage without confirmation, to minimize
-			# disruption of the rerere workflow
-			merge_add_resolution $current_diff_path
-			return
-		}
-
 		1 { set target [mc "the base version"] }
 		2 { set target [mc "this branch"] }
 		3 { set target [mc "the other branch"] }
@@ -29,6 +23,33 @@ This operation can be undone only by restarting the merge." \
 	}
 }
 
+proc merge_stage_workdir {path w lno} {
+	global current_diff_path diff_active
+
+	if {$diff_active} return
+
+	if {$path ne $current_diff_path} {
+		show_diff $path $w $lno {} [list do_merge_stage_workdir $path]
+	} else {
+		do_merge_stage_workdir $path
+	}
+}
+
+proc do_merge_stage_workdir {path} {
+	global current_diff_path is_conflict_diff
+
+	if {$path ne $current_diff_path} return;
+
+	if {$is_conflict_diff} {
+		if {[ask_popup [mc "File %s seems to have unresolved conflicts, still stage?" \
+				[short_path $path]]] ne {yes}} {
+			return
+		}
+	}
+
+	merge_add_resolution $path
+}
+
 proc merge_add_resolution {path} {
 	global current_diff_path ui_workdir
 
Signature · 1 line
1.6.0.20.g6148bc
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Alexander Gavrilov

This restores functionality of the file icon for unmerged files. Safety is enforced by loading the diff and checking for lines that look like conflict markers. If such lines are found, or the conflict involves deletion and/or symlinks, a confirmation dialog is presented. Otherwise, the icon immediately stages the working copy version of the file.

Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca (Restore ability to Stage Working Copy for conflicts)

Thanks, works fine after a brief test:

-- Hannes

#2 lore raw
In reply to Alexander Gavrilov
Quoted 10 lines · Alexander Gavrilov

This restores functionality of the file icon for unmerged files. Safety is enforced by loading the diff and checking for lines that look like conflict markers. If such lines are found, or the conflict involves deletion and/or symlinks, a confirmation dialog is presented. Otherwise, the icon immediately stages the working copy version of the file.

Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca (Restore ability to Stage Working Copy for conflicts)

Quoted 6 lines
---
 git-gui.sh        |   18 ++++++++----------
 lib/diff.tcl      |   52 +++++++++++++++++++++++++++++++++++-----------------
 lib/mergetool.tcl |   33 +++++++++++++++++++++++++++------
 3 files changed, 70 insertions(+), 33 deletions(-)

Can I get a resend of this patch?

I don't seem to have the base objects it applies to, and it doesn't apply clean to any branch I can find... :-|

Signature · 1 line
Shawn.
#3 lore raw
Quoted 8 lines · Shawn O. Pearce
Quoted 7 lines · Alexander Gavrilov

This restores functionality of the file icon for unmerged files. Safety is enforced by loading the diff and checking for lines that look like conflict markers. If such lines are found, or the conflict involves deletion and/or symlinks, a confirmation dialog is presented. Otherwise, the icon immediately stages the working copy version of the file.

Quoted 4 lines
Quoted 2 lines

Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca (Restore ability to Stage Working Copy for conflicts)

Can I get a resend of this patch?

Never mind. Its applied now. I broke down after lunch and found the one hunk that was an issue, and trivially hand merged it.

Signature · 1 line
Shawn.