git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] git-gui: Add a special diff popup menu for submodules
@ 2010-01-02 16:57 Jens Lehmann
  2010-01-02 16:58 ` [PATCH 1/2] git-gui: Unstaging a partly staged entry didn't update file_states correctly Jens Lehmann
  2010-01-02 16:58 ` [PATCH 2/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
  0 siblings, 2 replies; 4+ messages in thread
From: Jens Lehmann @ 2010-01-02 16:57 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Git Mailing List

The first patch is a resend (first sent on December 7th 2009) and
necessary for the second patch to work properly.

Jens Lehmann (2):
  git-gui: Unstaging a partly staged entry didn't update file_states
    correctly
  git-gui: Add a special diff popup menu for submodules

 git-gui/git-gui.sh |  130 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 113 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] git-gui: Unstaging a partly staged entry didn't update file_states correctly
  2010-01-02 16:57 [PATCH 0/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
@ 2010-01-02 16:58 ` Jens Lehmann
  2010-01-02 16:58 ` [PATCH 2/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Lehmann @ 2010-01-02 16:58 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Git Mailing List

When unstaging a partly staged file or submodule, the file_states list
was not updated properly (unless unstaged linewise). Its index_info part
did not contain the former head_info as it should have.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 git-gui/git-gui.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 718277a..e0dd5b5 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1613,6 +1613,9 @@ proc merge_state {path new_state {head_info {}} {index_info {}}} {
 	} elseif {$s0 ne {_} && [string index $state 0] eq {_}
 		&& $head_info eq {}} {
 		set head_info $index_info
+	} elseif {$s0 eq {_} && [string index $state 0] ne {_}} {
+		set index_info $head_info
+		set head_info {}
 	}

 	set file_states($path) [list $s0$s1 $icon \
-- 
1.6.6.339.g7cacc

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] git-gui: Add a special diff popup menu for submodules
  2010-01-02 16:57 [PATCH 0/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
  2010-01-02 16:58 ` [PATCH 1/2] git-gui: Unstaging a partly staged entry didn't update file_states correctly Jens Lehmann
@ 2010-01-02 16:58 ` Jens Lehmann
  2010-01-23 22:57   ` Shawn O. Pearce
  1 sibling, 1 reply; 4+ messages in thread
From: Jens Lehmann @ 2010-01-02 16:58 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Git Mailing List

To make it easier for users to deal with submodules, a special diff popup
menu has been added for submodules. The "Show Less Context" and "Show More
Context" entries have been removed, as they don't make any sense for a
submodule summary. Four new entries are added to the top of the popup menu
to gain access to more detailed information about the changes in a
submodule than the plain summary does offer. These are:
- "Visualize These Changes In The Submodule"
  starts gitk showing the selected commit range
- "Visualize These Changes In The Submodule"
  starts gitk showing the whole submodule history of the current branch
- "Visualize All Branch History In The Submodule"
  starts gitk --all in the submodule
- "Start git gui In The Submodule"
  guess what :-)

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 git-gui/git-gui.sh |  127 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 110 insertions(+), 17 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index e0dd5b5..ee80d7d 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1923,7 +1923,9 @@ proc incr_font_size {font {amt 1}} {

 set starting_gitk_msg [mc "Starting gitk... please wait..."]

-proc do_gitk {revs} {
+proc do_gitk {revs {is_submodule false}} {
+	global current_diff_path file_states current_diff_side ui_index
+
 	# -- Always start gitk through whatever we were loaded with.  This
 	#    lets us bypass using shell process on Windows systems.
 	#
@@ -1941,14 +1943,72 @@ proc do_gitk {revs} {
 		}

 		set pwd [pwd]
-		cd [file dirname [gitdir]]
-		set env(GIT_DIR) [file tail [gitdir]]
-
+		if {!$is_submodule} {
+			cd [file dirname [gitdir]]
+			set env(GIT_DIR) [file tail [gitdir]]
+		} else {
+			cd $current_diff_path
+			if {$revs eq {--}} {
+				set s $file_states($current_diff_path)
+				set old_sha1 {}
+				set new_sha1 {}
+				switch -glob -- [lindex $s 0] {
+				M_ { set old_sha1 [lindex [lindex $s 2] 1] }
+				_M { set old_sha1 [lindex [lindex $s 3] 1] }
+				MM {
+					if {$current_diff_side eq $ui_index} {
+						set old_sha1 [lindex [lindex $s 2] 1]
+						set new_sha1 [lindex [lindex $s 3] 1]
+					} else {
+						set old_sha1 [lindex [lindex $s 3] 1]
+					}
+				}
+				}
+				set revs $old_sha1...$new_sha1
+			}
+			if {[info exists env(GIT_DIR)]} {
+				unset env(GIT_DIR)
+			}
+		}
 		eval exec $cmd $revs &

-		if {$old_GIT_DIR eq {}} {
+		if {$old_GIT_DIR ne {}} {
+			set env(GIT_DIR) $old_GIT_DIR
+		}
+		cd $pwd
+
+		ui_status $::starting_gitk_msg
+		after 10000 {
+			ui_ready $starting_gitk_msg
+		}
+	}
+}
+
+proc do_git_gui {} {
+	global current_diff_path
+
+	# -- Always start git gui through whatever we were loaded with.  This
+	#    lets us bypass using shell process on Windows systems.
+	#
+	set exe [_which git]
+	if {$exe eq {}} {
+		error_popup [mc "Couldn't find git gui in PATH"]
+	} else {
+		global env
+
+		if {[info exists env(GIT_DIR)]} {
+			set old_GIT_DIR $env(GIT_DIR)
 			unset env(GIT_DIR)
 		} else {
+			set old_GIT_DIR {}
+		}
+
+		set pwd [pwd]
+		cd $current_diff_path
+
+		eval exec $exe gui &
+
+		if {$old_GIT_DIR ne {}} {
 			set env(GIT_DIR) $old_GIT_DIR
 		}
 		cd $pwd
@@ -3143,15 +3203,6 @@ $ui_diff tag raise sel

 proc create_common_diff_popup {ctxm} {
 	$ctxm add command \
-		-label [mc "Show Less Context"] \
-		-command show_less_context
-	lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
-	$ctxm add command \
-		-label [mc "Show More Context"] \
-		-command show_more_context
-	lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
-	$ctxm add separator
-	$ctxm add command \
 		-label [mc Refresh] \
 		-command reshow_diff
 	lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
@@ -3206,6 +3257,15 @@ $ctxm add command \
 set ui_diff_applyline [$ctxm index last]
 lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
 $ctxm add separator
+$ctxm add command \
+	-label [mc "Show Less Context"] \
+	-command show_less_context
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+	-label [mc "Show More Context"] \
+	-command show_more_context
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add separator
 create_common_diff_popup $ctxm

 set ctxmmg .vpane.lower.diff.body.ctxmmg
@@ -3228,9 +3288,40 @@ $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 "Show Less Context"] \
+	-command show_less_context
+lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
+$ctxmmg add command \
+	-label [mc "Show More Context"] \
+	-command show_more_context
+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} {
+set ctxmsm .vpane.lower.diff.body.ctxmsm
+menu $ctxmsm -tearoff 0
+$ctxmsm add command \
+	-label [mc "Visualize These Changes In The Submodule"] \
+	-command {do_gitk -- true}
+lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
+$ctxmsm add command \
+	-label [mc "Visualize Current Branch History In The Submodule"] \
+	-command {do_gitk {} true}
+lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
+$ctxmsm add command \
+	-label [mc "Visualize All Branch History In The Submodule"] \
+	-command {do_gitk --all true}
+lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
+$ctxmsm add separator
+$ctxmsm add command \
+	-label [mc "Start git gui In The Submodule"] \
+	-command {do_git_gui}
+lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
+$ctxmsm add separator
+create_common_diff_popup $ctxmsm
+
+proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
 	global current_diff_path file_states
 	set ::cursorX $x
 	set ::cursorY $y
@@ -3241,6 +3332,8 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
 	}
 	if {[string first {U} $state] >= 0} {
 		tk_popup $ctxmmg $X $Y
+	} elseif {$::is_submodule_diff} {
+		tk_popup $ctxmsm $X $Y
 	} else {
 		if {$::ui_index eq $::current_diff_side} {
 			set l [mc "Unstage Hunk From Commit"]
@@ -3249,7 +3342,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 || $::is_submodule_diff
+		if {$::is_3way_diff
 			|| $current_diff_path eq {}
 			|| {__} eq $state
 			|| {_O} eq $state
@@ -3264,7 +3357,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
 		tk_popup $ctxm $X $Y
 	}
 }
-bind_button3 $ui_diff [list popup_diff_menu $ctxm $ctxmmg %x %y %X %Y]
+bind_button3 $ui_diff [list popup_diff_menu $ctxm $ctxmmg $ctxmsm %x %y %X %Y]

 # -- Status Bar
 #
-- 
1.6.6.339.g7cacc

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] git-gui: Add a special diff popup menu for submodules
  2010-01-02 16:58 ` [PATCH 2/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
@ 2010-01-23 22:57   ` Shawn O. Pearce
  0 siblings, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2010-01-23 22:57 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Git Mailing List

Jens Lehmann <Jens.Lehmann@web.de> wrote:
> To make it easier for users to deal with submodules, a special diff popup
> menu has been added for submodules. The "Show Less Context" and "Show More
> Context" entries have been removed, as they don't make any sense for a
> submodule summary. Four new entries are added to the top of the popup menu
> to gain access to more detailed information about the changes in a
> submodule than the plain summary does offer. These are:
> - "Visualize These Changes In The Submodule"
>   starts gitk showing the selected commit range
> - "Visualize These Changes In The Submodule"
>   starts gitk showing the whole submodule history of the current branch
> - "Visualize All Branch History In The Submodule"
>   starts gitk --all in the submodule
> - "Start git gui In The Submodule"
>   guess what :-)
> 
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
>  git-gui/git-gui.sh |  127 +++++++++++++++++++++++++++++++++++++++++++++-------
>  1 files changed, 110 insertions(+), 17 deletions(-)

Thanks, applied.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-23 22:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-02 16:57 [PATCH 0/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
2010-01-02 16:58 ` [PATCH 1/2] git-gui: Unstaging a partly staged entry didn't update file_states correctly Jens Lehmann
2010-01-02 16:58 ` [PATCH 2/2] git-gui: Add a special diff popup menu for submodules Jens Lehmann
2010-01-23 22:57   ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).