[PATCH] Offer to print changes while running git-mergetool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a "Show changes" option to each prompt in mergetool. This prints the conflicted changes on the current file, using 'git log -p --merge <file>'

Signed-off-by: Jonathan del Strother <jon.delStrother@xxxxxxxxxxxxx>
---

I frequently find myself running git-mergetool, then finding halfway through that I need to review the changes that produced that conflict.
How about something like this, for showing the changes from within mergetool?

 git-mergetool.sh |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 87fa88a..9df91d8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -62,7 +62,7 @@ describe_file () {
 
 resolve_symlink_merge () {
     while true; do
-	printf "Use (l)ocal or (r)emote, or (a)bort? "
+	printf "Use (l)ocal or (r)emote, (s)how changes, or (a)bort? "
 	read ans
 	case "$ans" in
 	    [lL]*)
@@ -77,6 +77,12 @@ resolve_symlink_merge () {
 		cleanup_temp_files --save-backup
 		return 0
 		;;
+		[sS]*)
+		git log -p --merge "$MERGED"
+		printf "\n"
+		resolve_symlink_merge
+		return
+		;;
 	    [aA]*)
 		return 1
 		;;
@@ -87,9 +93,9 @@ resolve_symlink_merge () {
 resolve_deleted_merge () {
     while true; do
 	if base_present; then
-	    printf "Use (m)odified or (d)eleted file, or (a)bort? "
+	    printf "Use (m)odified or (d)eleted file, (s)how changes, or (a)bort? "
 	else
-	    printf "Use (c)reated or (d)eleted file, or (a)bort? "
+	    printf "Use (c)reated or (d)eleted file, (s)how changes, or (a)bort? "
 	fi
 	read ans
 	case "$ans" in
@@ -103,6 +109,12 @@ resolve_deleted_merge () {
 		cleanup_temp_files
 		return 0
 		;;
+		[sS]*)
+		git log -p --merge "$MERGED"
+		printf "\n"
+		resolve_deleted_merge
+		return
+		;;
 	    [aA]*)
 		return 1
 		;;
@@ -183,10 +195,21 @@ merge_file () {
     echo "Normal merge conflict for '$MERGED':"
     describe_file "$local_mode" "local" "$LOCAL"
     describe_file "$remote_mode" "remote" "$REMOTE"
-    if "$prompt" = true; then
-	printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
-	read ans
-    fi
+	if "$prompt" = true; then
+		while true; do
+			printf "(S)how changes, or hit return to start merge resolution tool (%s): " "$merge_tool"
+			read ans
+			case "$ans" in
+				[sS]*)
+				git log -p --merge "$MERGED"
+				printf "\n"
+				;;
+				*)
+				break
+				;;
+			esac
+		done
+	fi
 
     case "$merge_tool" in
 	kdiff3)
-- 
1.6.1.2.390.gba743.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux