From 9b28a8b9c2051bf85f71cdec85c142a0ab561f10 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 26 Feb 2007 11:17:11 -0500 Subject: [PATCH 1/5] git-gui: Relocate the menu/transport menu code. This code doesn't belong down in the main window UI creation, its really part of the menu system and probably should be located with it. I'm moving it because I could not find the code when I was looking for it earlier today, as it was not where I expected it to be found. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index f84ba3382b..48097ea5e8 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -5330,6 +5330,34 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { [list .mbar.commit entryconf [.mbar.commit index last] -state] } +# -- Merge Menu +# +if {[is_enabled branch]} { + menu .mbar.merge + .mbar.merge add command -label {Local Merge...} \ + -command do_local_merge \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.merge entryconf [.mbar.merge index last] -state] + .mbar.merge add command -label {Abort Merge...} \ + -command do_reset_hard \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.merge entryconf [.mbar.merge index last] -state] + +} + +# -- Transport Menu +# +if {[is_enabled transport]} { + menu .mbar.fetch + + menu .mbar.push + .mbar.push add command -label {Push...} \ + -command do_push_anywhere \ + -font font_ui +} + if {[is_MacOSX]} { # -- Apple Menu (Mac OS X only) # @@ -5502,28 +5530,6 @@ pack .branch.l1 -side left pack .branch.cb -side left -fill x pack .branch -side top -fill x -if {[is_enabled branch]} { - menu .mbar.merge - .mbar.merge add command -label {Local Merge...} \ - -command do_local_merge \ - -font font_ui - lappend disable_on_lock \ - [list .mbar.merge entryconf [.mbar.merge index last] -state] - .mbar.merge add command -label {Abort Merge...} \ - -command do_reset_hard \ - -font font_ui - lappend disable_on_lock \ - [list .mbar.merge entryconf [.mbar.merge index last] -state] - - - menu .mbar.fetch - - menu .mbar.push - .mbar.push add command -label {Push...} \ - -command do_push_anywhere \ - -font font_ui -} - # -- Main Window Layout # panedwindow .vpane -orient vertical From fd234dfdb7ee1955922ded27ed18df59259193d9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 26 Feb 2007 11:22:10 -0500 Subject: [PATCH 2/5] git-gui: Add Reset to the Branch menu. cehteh on #git noticed that there was no way to perform a reset --hard from within git-gui. When I pointed out this was Merge->Abort Merge cehteh said this is not very understandable, and that most users would never guess to try that option unless they were actually in a merge. So Branch->Reset is now also a way to cause a reset --hard from within the UI. Right now the confirmation dialog is the same as the one used in Merge->Abort Merge. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 48097ea5e8..36155bb8ea 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -5256,6 +5256,12 @@ if {[is_enabled branch]} { -font font_ui lappend disable_on_lock [list .mbar.branch entryconf \ [.mbar.branch index last] -state] + + .mbar.branch add command -label {Reset...} \ + -command do_reset_hard \ + -font font_ui + lappend disable_on_lock [list .mbar.branch entryconf \ + [.mbar.branch index last] -state] } # -- Commit Menu From 51bd9d7b8cf29e0e441531fb0a671cc7093f278b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 26 Feb 2007 11:47:14 -0500 Subject: [PATCH 3/5] git-gui: Don't create empty (same tree as parent) commits. Mark Levedahl noticed that git-gui will let you create an empty normal (non-merge) commit if the file state in the index is out of whack. The case Mark was looking at was with the new autoCRLF feature in git enabled and is actually somewhat difficult to create. I found a different way to create an empty commit: turn on the Trust File Modifications flag, touch a file, rescan, then move the file into the "Changes To Be Committed" list without looking at the file's diff. This makes git-gui think there are files staged for commit, yet the update-index call did nothing other than refresh the stat information for the affected file. In this case git-gui allowed the user to make a commit that did not actually change anything in the repository. Creating empty commits is usually a pointless operation; rarely does it record useful information. More often than not an empty commit is actually an indication that the user did not properly update their index prior to commit. We should help the user out by detecting this possible mistake and guiding them through it, rather than blindly recording it. After we get the new tree name back from write-tree we compare it to the parent commit's tree; if they are the same string and this is a normal (non-merge, non-amend) commit then something fishy is going on. The user is making an empty commit, but they most likely don't want to do that. We now pop an informational dialog and start a rescan, aborting the commit. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 36155bb8ea..743099c573 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1267,6 +1267,24 @@ proc commit_committree {fd_wt curHEAD msg} { return } + # -- Verify this wasn't an empty change. + # + if {$commit_type eq {normal}} { + set old_tree [git rev-parse "$PARENT^{tree}"] + if {$tree_id eq $old_tree} { + info_popup {No changes to commit. + +No files were modified by this commit and it +was not a merge commit. + +A rescan will be automatically started now. +} + unlock_index + rescan {set ui_status_value {No changes to commit.}} + return + } + } + # -- Build the message. # set msg_p [gitdir COMMIT_EDITMSG] From c3e8a0a4ddb7d32970c49117e0386a3b1c182413 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 1 Mar 2007 14:37:34 -0500 Subject: [PATCH 4/5] git-gui: Remove unnecessary /dev/null redirection. Git 1.5.0 and later no longer output useless messages to standard error when making the initial (or what looks to be) commit of a repository. Since /dev/null does not exist on Windows in the MinGW environment we can't redirect there anyway. Since Git does not output anymore, I'm removing the redirection. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 743099c573..1981827a8e 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1299,14 +1299,8 @@ A rescan will be automatically started now. # -- Create the commit. # set cmd [list git commit-tree $tree_id] - set parents [concat $PARENT $MERGE_HEAD] - if {[llength $parents] > 0} { - foreach p $parents { - lappend cmd -p $p - } - } else { - # git commit-tree writes to stderr during initial commit. - lappend cmd 2>/dev/null + foreach p [concat $PARENT $MERGE_HEAD] { + lappend cmd -p $p } lappend cmd <$msg_p if {[catch {set cmt_id [eval exec $cmd]} err]} { From 0b5ea163d21163343579cd6eb9274ccc2190a0fe Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 6 Mar 2007 02:13:23 -0500 Subject: [PATCH 5/5] git-gui: Make 'make' quieter by default To fit nicely into the output of the git.git project's own quieter Makefile, we want to make the git-gui Makefile nice and quiet too. Signed-off-by: Shawn O. Pearce --- Makefile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 66538ba1ad..e486e8f984 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ all:: +# Define V=1 to have a more verbose compile. +# + GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN -include GIT-VERSION-FILE @@ -19,27 +22,32 @@ ifndef INSTALL INSTALL = install endif +ifndef V + QUIET_GEN = @echo ' ' GEN $@; + QUIET_BUILT_IN = @echo ' ' BUILTIN $@; +endif + DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) git-gui: git-gui.sh GIT-VERSION-FILE CREDITS-FILE - rm -f $@ $@+ + $(QUIET_GEN)rm -f $@ $@+ && \ sed -n \ -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \ -e '1,/^set gitgui_credits /p' \ - $@.sh >$@+ - cat CREDITS-FILE >>$@+ - sed -e '1,/^set gitgui_credits /d' $@.sh >>$@+ - chmod +x $@+ + $@.sh >$@+ && \ + cat CREDITS-FILE >>$@+ && \ + sed -e '1,/^set gitgui_credits /d' $@.sh >>$@+ && \ + chmod +x $@+ && \ mv $@+ $@ CREDITS-FILE: CREDITS-GEN .FORCE-CREDITS-FILE - $(SHELL_PATH) ./CREDITS-GEN + $(QUIET_GEN)$(SHELL_PATH) ./CREDITS-GEN $(GITGUI_BUILT_INS): git-gui - rm -f $@ && ln git-gui $@ + $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@ all:: $(ALL_PROGRAMS)