{"thread":{"id":"18630","subject":"(unknown)","startedAt":"2009-03-30T05:03:40Z","lastAt":"2009-04-01T17:56:32Z","messageCount":19,"participants":["David Aguilar","Markus Heidelberg","Junio C Hamano","Charles Bailey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"109819","messageId":"1238389428-69328-1-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":null,"subject":"(unknown)","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:40Z","receivedAt":"2009-03-30T05:03:40Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"As promised, here is the patch series that removes the duplicate\ncode between git-difftool and git-mergetool.\n\nThis is based on top of Junio's \"pu\" branch and is a\ncontinuation of the recent difftool series.\n\nI created a new git-sh-tools shell lib for holding the\ncommon functions.  If anyone thinks I should have placed the\nfunctions in git-sh-setup instead then just let me know.\n\nHere's a total diffstat.  If it wasn't for the documentation\nand replacing the mixed spaces/tabs with all-tabs in\ngit-mergetool then we would have seen a lot more\nhappy removals.\n\n .gitignore                     |    1 +\n Documentation/git-sh-tools.txt |   52 ++++\n Makefile                       |    1 +\n command-list.txt               |    1 +\n git-difftool-helper.sh         |  112 +-------\n git-mergetool.sh               |  639 ++++++++++++++++------------------------\n git-sh-tools.sh                |  181 ++++++++++++\n 7 files changed, 506 insertions(+), 481 deletions(-)\n\nGIT:\nFrom: David Aguilar <davvid@gmail.com>\nSubject: Refactor git-{diff,merge}tool to remove duplicate code\nIn-Reply-To: \n"},{"id":"109825","messageId":"1238389428-69328-2-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-1-git-send-email-davvid@gmail.com","subject":"[PATCH 1/8] mergetool: use tabs consistently","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:41Z","receivedAt":"2009-03-30T05:03:41Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This makes mergetool use hard tabs throughout.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh |  694 +++++++++++++++++++++++++++--------------------------\n 1 files changed, 354 insertions(+), 340 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 87fa88a..cfee28e 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -16,336 +16,351 @@ require_work_tree\n \n # Returns true if the mode reflects a symlink\n is_symlink () {\n-    test \"$1\" = 120000\n+\ttest \"$1\" = 120000\n }\n \n local_present () {\n-    test -n \"$local_mode\"\n+\ttest -n \"$local_mode\"\n }\n \n remote_present () {\n-    test -n \"$remote_mode\"\n+\ttest -n \"$remote_mode\"\n }\n \n base_present () {\n-    test -n \"$base_mode\"\n+\ttest -n \"$base_mode\"\n }\n \n cleanup_temp_files () {\n-    if test \"$1\" = --save-backup ; then\n-\tmv -- \"$BACKUP\" \"$MERGED.orig\"\n-\trm -f -- \"$LOCAL\" \"$REMOTE\" \"$BASE\"\n-    else\n-\trm -f -- \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$BACKUP\"\n-    fi\n+\tif test \"$1\" = --save-backup ; then\n+\t\tmv -- \"$BACKUP\" \"$MERGED.orig\"\n+\t\trm -f -- \"$LOCAL\" \"$REMOTE\" \"$BASE\"\n+\telse\n+\t\trm -f -- \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$BACKUP\"\n+\tfi\n }\n \n describe_file () {\n-    mode=\"$1\"\n-    branch=\"$2\"\n-    file=\"$3\"\n-\n-    printf \"  {%s}: \" \"$branch\"\n-    if test -z \"$mode\"; then\n-\techo \"deleted\"\n-    elif is_symlink \"$mode\" ; then\n-\techo \"a symbolic link -> '$(cat \"$file\")'\"\n-    else\n-\tif base_present; then\n-\t    echo \"modified\"\n+\tmode=\"$1\"\n+\tbranch=\"$2\"\n+\tfile=\"$3\"\n+\n+\tprintf \"  {%s}: \" \"$branch\"\n+\tif test -z \"$mode\"; then\n+\t\techo \"deleted\"\n+\telif is_symlink \"$mode\" ; then\n+\t\techo \"a symbolic link -> '$(cat \"$file\")'\"\n \telse\n-\t    echo \"created\"\n+\t\tif base_present; then\n+\t\t\techo \"modified\"\n+\t\telse\n+\t\t\techo \"created\"\n+\t\tfi\n \tfi\n-    fi\n }\n \n \n resolve_symlink_merge () {\n-    while true; do\n-\tprintf \"Use (l)ocal or (r)emote, or (a)bort? \"\n-\tread ans\n-\tcase \"$ans\" in\n-\t    [lL]*)\n-\t\tgit checkout-index -f --stage=2 -- \"$MERGED\"\n-\t\tgit add -- \"$MERGED\"\n-\t\tcleanup_temp_files --save-backup\n-\t\treturn 0\n-\t\t;;\n-\t    [rR]*)\n-\t\tgit checkout-index -f --stage=3 -- \"$MERGED\"\n-\t\tgit add -- \"$MERGED\"\n-\t\tcleanup_temp_files --save-backup\n-\t\treturn 0\n-\t\t;;\n-\t    [aA]*)\n-\t\treturn 1\n-\t\t;;\n-\t    esac\n+\twhile true; do\n+\t\tprintf \"Use (l)ocal or (r)emote, or (a)bort? \"\n+\t\tread ans\n+\t\tcase \"$ans\" in\n+\t\t[lL]*)\n+\t\t\tgit checkout-index -f --stage=2 -- \"$MERGED\"\n+\t\t\tgit add -- \"$MERGED\"\n+\t\t\tcleanup_temp_files --save-backup\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\t[rR]*)\n+\t\t\tgit checkout-index -f --stage=3 -- \"$MERGED\"\n+\t\t\tgit add -- \"$MERGED\"\n+\t\t\tcleanup_temp_files --save-backup\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\t[aA]*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\t\tesac\n \tdone\n }\n \n resolve_deleted_merge () {\n-    while true; do\n-\tif base_present; then\n-\t    printf \"Use (m)odified or (d)eleted file, or (a)bort? \"\n-\telse\n-\t    printf \"Use (c)reated or (d)eleted file, or (a)bort? \"\n-\tfi\n-\tread ans\n-\tcase \"$ans\" in\n-\t    [mMcC]*)\n-\t\tgit add -- \"$MERGED\"\n-\t\tcleanup_temp_files --save-backup\n-\t\treturn 0\n-\t\t;;\n-\t    [dD]*)\n-\t\tgit rm -- \"$MERGED\" > /dev/null\n-\t\tcleanup_temp_files\n-\t\treturn 0\n-\t\t;;\n-\t    [aA]*)\n-\t\treturn 1\n-\t\t;;\n-\t    esac\n+\twhile true; do\n+\t\tif base_present; then\n+\t\t\tprintf \"Use (m)odified or (d)eleted file, or (a)bort? \"\n+\t\telse\n+\t\t\tprintf \"Use (c)reated or (d)eleted file, or (a)bort? \"\n+\t\tfi\n+\t\tread ans\n+\t\tcase \"$ans\" in\n+\t\t[mMcC]*)\n+\t\t\tgit add -- \"$MERGED\"\n+\t\t\tcleanup_temp_files --save-backup\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\t[dD]*)\n+\t\t\tgit rm -- \"$MERGED\" > /dev/null\n+\t\t\tcleanup_temp_files\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\t[aA]*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\t\tesac\n \tdone\n }\n \n check_unchanged () {\n-    if test \"$MERGED\" -nt \"$BACKUP\" ; then\n-\tstatus=0;\n-    else\n-\twhile true; do\n-\t    echo \"$MERGED seems unchanged.\"\n-\t    printf \"Was the merge successful? [y/n] \"\n-\t    read answer < /dev/tty\n-\t    case \"$answer\" in\n-\t\ty*|Y*) status=0; break ;;\n-\t\tn*|N*) status=1; break ;;\n-\t    esac\n-\tdone\n-    fi\n+\tif test \"$MERGED\" -nt \"$BACKUP\" ; then\n+\t\tstatus=0;\n+\telse\n+\t\twhile true; do\n+\t\t\techo \"$MERGED seems unchanged.\"\n+\t\t\tprintf \"Was the merge successful? [y/n] \"\n+\t\t\tread answer < /dev/tty\n+\t\t\tcase \"$answer\" in\n+\t\t\ty*|Y*) status=0; break ;;\n+\t\t\tn*|N*) status=1; break ;;\n+\t\t\tesac\n+\t\tdone\n+\tfi\n }\n \n checkout_staged_file () {\n-    tmpfile=$(expr \"$(git checkout-index --temp --stage=\"$1\" \"$2\")\" : '\\([^\t]*\\)\t')\n+\tcheckouttmp=$(git checkout-index --temp --stage=\"$1\" \"$2\")\n+\ttmpfile=$(expr \"$checkouttmp\" : '\\([^\t]*\\)\t')\n \n-    if test $? -eq 0 -a -n \"$tmpfile\" ; then\n-\tmv -- \"$(git rev-parse --show-cdup)$tmpfile\" \"$3\"\n-    fi\n+\tif test $? -eq 0 -a -n \"$tmpfile\" ; then\n+\t\tmv -- \"$(git rev-parse --show-cdup)$tmpfile\" \"$3\"\n+\tfi\n }\n \n merge_file () {\n-    MERGED=\"$1\"\n+\tMERGED=\"$1\"\n \n-    f=`git ls-files -u -- \"$MERGED\"`\n-    if test -z \"$f\" ; then\n-\tif test ! -f \"$MERGED\" ; then\n-\t    echo \"$MERGED: file not found\"\n-\telse\n-\t    echo \"$MERGED: file does not need merging\"\n+\tf=`git ls-files -u -- \"$MERGED\"`\n+\tif test -z \"$f\" ; then\n+\t\tif test ! -f \"$MERGED\" ; then\n+\t\t\techo \"$MERGED: file not found\"\n+\t\telse\n+\t\t\techo \"$MERGED: file does not need merging\"\n+\t\tfi\n+\t\treturn 1\n \tfi\n-\treturn 1\n-    fi\n-\n-    ext=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n-    BACKUP=\"./$MERGED.BACKUP.$ext\"\n-    LOCAL=\"./$MERGED.LOCAL.$ext\"\n-    REMOTE=\"./$MERGED.REMOTE.$ext\"\n-    BASE=\"./$MERGED.BASE.$ext\"\n \n-    mv -- \"$MERGED\" \"$BACKUP\"\n-    cp -- \"$BACKUP\" \"$MERGED\"\n-\n-    base_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n-    local_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n-    remote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n+\text=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n+\tBACKUP=\"./$MERGED.BACKUP.$ext\"\n+\tLOCAL=\"./$MERGED.LOCAL.$ext\"\n+\tREMOTE=\"./$MERGED.REMOTE.$ext\"\n+\tBASE=\"./$MERGED.BASE.$ext\"\n+\n+\tmv -- \"$MERGED\" \"$BACKUP\"\n+\tcp -- \"$BACKUP\" \"$MERGED\"\n+\n+\tbase_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n+\tlocal_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n+\tremote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n+\n+\tbase_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+\tlocal_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n+\tremote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+\n+\tif test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n+\t\techo \"Deleted merge conflict for '$MERGED':\"\n+\t\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n+\t\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n+\t\tresolve_deleted_merge\n+\t\treturn\n+\tfi\n \n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n-    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n-    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+\tif is_symlink \"$local_mode\" || is_symlink \"$remote_mode\"; then\n+\t\techo \"Symbolic link merge conflict for '$MERGED':\"\n+\t\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n+\t\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n+\t\tresolve_symlink_merge\n+\t\treturn\n+\tfi\n \n-    if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n-\techo \"Deleted merge conflict for '$MERGED':\"\n+\techo \"Normal merge conflict for '$MERGED':\"\n \tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n \tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n-\tresolve_deleted_merge\n-\treturn\n-    fi\n+\tif \"$prompt\" = true; then\n+\t\tprintf \"Hit return to start merge resolution tool (%s): \" \"$merge_tool\"\n+\t\tread ans\n+\tfi\n \n-    if is_symlink \"$local_mode\" || is_symlink \"$remote_mode\"; then\n-\techo \"Symbolic link merge conflict for '$MERGED':\"\n-\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n-\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n-\tresolve_symlink_merge\n-\treturn\n-    fi\n-\n-    echo \"Normal merge conflict for '$MERGED':\"\n-    describe_file \"$local_mode\" \"local\" \"$LOCAL\"\n-    describe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n-    if \"$prompt\" = true; then\n-\tprintf \"Hit return to start merge resolution tool (%s): \" \"$merge_tool\"\n-\tread ans\n-    fi\n-\n-    case \"$merge_tool\" in\n+\tcase \"$merge_tool\" in\n \tkdiff3)\n-\t    if base_present ; then\n-\t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Base)\" --L2 \"$MERGED (Local)\" --L3 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n-\t    else\n-\t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Local)\" --L2 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n-\t    fi\n-\t    status=$?\n-\t    ;;\n+\t\tif base_present ; then\n+\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t--L1 \"$MERGED (Base)\" \\\n+\t\t\t\t--L2 \"$MERGED (Local)\" \\\n+\t\t\t\t--L3 \"$MERGED (Remote)\" \\\n+\t\t\t\t-o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t > /dev/null 2>&1)\n+\t\telse\n+\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t--L1 \"$MERGED (Local)\" \\\n+\t\t\t\t--L2 \"$MERGED (Remote)\" \\\n+\t\t\t\t-o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t > /dev/null 2>&1)\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n \ttkdiff)\n-\t    if base_present ; then\n-\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    else\n-\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    fi\n-\t    status=$?\n-\t    ;;\n+\t\tif base_present ; then\n+\t\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n \tmeld)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tcheck_unchanged\n+\t\t;;\n \tvimdiff)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tcheck_unchanged\n+\t\t;;\n \tgvimdiff)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tcheck_unchanged\n+\t\t;;\n \txxdiff)\n-\t    touch \"$BACKUP\"\n-\t    if base_present ; then\n-\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n-\t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n-\t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t    --merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n-\t    else\n-\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n-\t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n-\t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t    --merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    fi\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\tif base_present ; then\n+\t\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n+\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n+\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n \topendiff)\n-\t    touch \"$BACKUP\"\n-\t    if base_present; then\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" | cat\n-\t    else\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -merge \"$MERGED\" | cat\n-\t    fi\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t-ancestor \"$BASE\" -merge \"$MERGED\" | cat\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t-merge \"$MERGED\" | cat\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n \tecmerge)\n-\t    touch \"$BACKUP\"\n-\t    if base_present; then\n-\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" --default --mode=merge3 --to=\"$MERGED\"\n-\t    else\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" --default --mode=merge2 --to=\"$MERGED\"\n-\t    fi\n-\t    check_unchanged\n-\t    ;;\n+\t\ttouch \"$BACKUP\"\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge3 --to=\"$MERGED\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n \temerge)\n-\t    if base_present ; then\n-\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$MERGED\")\"\n-\t    else\n-\t\t\"$merge_tool_path\" -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n-\t    fi\n-\t    status=$?\n-\t    ;;\n-\t*)\n-\t    if test -n \"$merge_tool_cmd\"; then\n-\t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n-\t\t    touch \"$BACKUP\"\n-\t\t    ( eval $merge_tool_cmd )\n-\t\t    check_unchanged\n+\t\tif base_present ; then\n+\t\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$MERGED\")\"\n \t\telse\n-\t\t    ( eval $merge_tool_cmd )\n-\t\t    status=$?\n+\t\t\t\"$merge_tool_path\" -f emerge-files-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n \t\tfi\n-\t    fi\n-\t    ;;\n-    esac\n-    if test \"$status\" -ne 0; then\n-\techo \"merge of $MERGED failed\" 1>&2\n-\tmv -- \"$BACKUP\" \"$MERGED\"\n-\n-\tif test \"$merge_keep_temporaries\" = \"false\"; then\n-\t    cleanup_temp_files\n-\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\t*)\n+\t\tif test -n \"$merge_tool_cmd\"; then\n+\t\t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n+\t\t\t\ttouch \"$BACKUP\"\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tcheck_unchanged\n+\t\t\telse\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tstatus=$?\n+\t\t\tfi\n+\t\tfi\n+\t\t;;\n+\tesac\n+\tif test \"$status\" -ne 0; then\n+\t\techo \"merge of $MERGED failed\" 1>&2\n+\t\tmv -- \"$BACKUP\" \"$MERGED\"\n \n-\treturn 1\n-    fi\n+\t\tif test \"$merge_keep_temporaries\" = \"false\"; then\n+\t\t\tcleanup_temp_files\n+\t\tfi\n \n-    if test \"$merge_keep_backup\" = \"true\"; then\n-\tmv -- \"$BACKUP\" \"$MERGED.orig\"\n-    else\n-\trm -- \"$BACKUP\"\n-    fi\n+\t\treturn 1\n+\tfi\n+\n+\tif test \"$merge_keep_backup\" = \"true\"; then\n+\t\tmv -- \"$BACKUP\" \"$MERGED.orig\"\n+\telse\n+\t\trm -- \"$BACKUP\"\n+\tfi\n \n-    git add -- \"$MERGED\"\n-    cleanup_temp_files\n-    return 0\n+\tgit add -- \"$MERGED\"\n+\tcleanup_temp_files\n+\treturn 0\n }\n \n prompt=$(git config --bool mergetool.prompt || echo true)\n \n while test $# != 0\n do\n-    case \"$1\" in\n+\tcase \"$1\" in\n \t-t|--tool*)\n-\t    case \"$#,$1\" in\n+\t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t    merge_tool=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n-\t\t    ;;\n+\t\t\tmerge_tool=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t\t;;\n \t\t1,*)\n-\t\t    usage ;;\n+\t\t\tusage ;;\n \t\t*)\n-\t\t    merge_tool=\"$2\"\n-\t\t    shift ;;\n-\t    esac\n-\t    ;;\n+\t\t\tmerge_tool=\"$2\"\n+\t\t\tshift ;;\n+\t\tesac\n+\t\t;;\n \t-y|--no-prompt)\n-\t    prompt=false\n-\t    ;;\n+\t\tprompt=false\n+\t\t;;\n \t--prompt)\n-\t    prompt=true\n-\t    ;;\n+\t\tprompt=true\n+\t\t;;\n \t--)\n-\t    shift\n-\t    break\n-\t    ;;\n+\t\tshift\n+\t\tbreak\n+\t\t;;\n \t-*)\n-\t    usage\n-\t    ;;\n+\t\tusage\n+\t\t;;\n \t*)\n-\t    break\n-\t    ;;\n-    esac\n-    shift\n+\t\tbreak\n+\t\t;;\n+\tesac\n+\tshift\n done\n \n valid_custom_tool()\n {\n-    merge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n-    test -n \"$merge_tool_cmd\"\n+\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n+\ttest -n \"$merge_tool_cmd\"\n }\n \n valid_tool() {\n \tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | \\\n+\t\temerge | vimdiff | gvimdiff | ecmerge)\n \t\t\t;; # happy\n \t\t*)\n \t\t\tif ! valid_custom_tool \"$1\"; then\n@@ -370,117 +385,116 @@ init_merge_tool_path() {\n }\n \n prompt_after_failed_merge() {\n-    while true; do\n-\tprintf \"Continue merging other unresolved paths (y/n) ? \"\n-\tread ans\n-\tcase \"$ans\" in\n-\n-\t    [yY]*)\n-\t\treturn 0\n-\t\t;;\n+\twhile true; do\n+\t\tprintf \"Continue merging other unresolved paths (y/n) ? \"\n+\t\tread ans\n+\t\tcase \"$ans\" in\n+\t\t[yY]*)\n+\t\t\treturn 0\n+\t\t\t;;\n \n-\t    [nN]*)\n-\t\treturn 1\n-\t\t;;\n-\tesac\n-    done\n+\t\t[nN]*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\t\tesac\n+\tdone\n }\n \n if test -z \"$merge_tool\"; then\n-    merge_tool=`git config merge.tool`\n-    if test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n-\t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n-\t    echo >&2 \"Resetting to default...\"\n-\t    unset merge_tool\n-    fi\n+\tmerge_tool=`git config merge.tool`\n+\tif test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n+\t\techo >&2 \"git config option merge.tool set to unknown tool:\" \"$merge_tool\"\n+\t\techo >&2 \"Resetting to default...\"\n+\t\tunset merge_tool\n+\tfi\n fi\n \n if test -z \"$merge_tool\" ; then\n-    if test -n \"$DISPLAY\"; then\n-        if test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff gvimdiff\"\n-        else\n-            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld gvimdiff\"\n-        fi\n-    fi\n-    if echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n-        merge_tool_candidates=\"$merge_tool_candidates emerge opendiff vimdiff\"\n-    elif echo \"${VISUAL:-$EDITOR}\" | grep 'vim' > /dev/null 2>&1; then\n-        merge_tool_candidates=\"$merge_tool_candidates vimdiff opendiff emerge\"\n-    else\n-        merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n-    fi\n-    echo \"merge tool candidates: $merge_tool_candidates\"\n-    for i in $merge_tool_candidates; do\n-        init_merge_tool_path $i\n-        if type \"$merge_tool_path\" > /dev/null 2>&1; then\n-            merge_tool=$i\n-            break\n-        fi\n-    done\n-    if test -z \"$merge_tool\" ; then\n-\techo \"No known merge resolution program available.\"\n-\texit 1\n-    fi\n+\tif test -n \"$DISPLAY\"; then\n+\t\tif test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n+\t\t\tmerge_tool_candidates=\"meld kdiff3 tkdiff xxdiff gvimdiff\"\n+\t\telse\n+\t\t\tmerge_tool_candidates=\"kdiff3 tkdiff xxdiff meld gvimdiff\"\n+\t\tfi\n+\tfi\n+\tif echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n+\t\tmerge_tool_candidates=\"$merge_tool_candidates emerge opendiff vimdiff\"\n+\telif echo \"${VISUAL:-$EDITOR}\" | grep 'vim' > /dev/null 2>&1; then\n+\t\tmerge_tool_candidates=\"$merge_tool_candidates vimdiff opendiff emerge\"\n+\telse\n+\t\tmerge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n+\tfi\n+\techo \"merge tool candidates: $merge_tool_candidates\"\n+\tfor i in $merge_tool_candidates; do\n+\t\tinit_merge_tool_path $i\n+\t\tif type \"$merge_tool_path\" > /dev/null 2>&1; then\n+\t\t\tmerge_tool=$i\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+\tif test -z \"$merge_tool\" ; then\n+\t\techo \"No known merge resolution program available.\"\n+\t\texit 1\n+\tfi\n else\n-    if ! valid_tool \"$merge_tool\"; then\n-        echo >&2 \"Unknown merge_tool $merge_tool\"\n-        exit 1\n-    fi\n+\tif ! valid_tool \"$merge_tool\"; then\n+\t\techo >&2 \"Unknown merge_tool $merge_tool\"\n+\t\texit 1\n+\tfi\n \n-    init_merge_tool_path \"$merge_tool\"\n+\tinit_merge_tool_path \"$merge_tool\"\n \n-    merge_keep_backup=\"$(git config --bool merge.keepBackup || echo true)\"\n-    merge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n+\tmerge_keep_backup=\"$(git config --bool merge.keepBackup || echo true)\"\n+\tmerge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n \n-    if test -z \"$merge_tool_cmd\" && ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n-        echo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n-        exit 1\n-    fi\n+\tif test -z \"$merge_tool_cmd\" && ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n+\t\techo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n+\t\texit 1\n+\tfi\n \n-    if ! test -z \"$merge_tool_cmd\"; then\n-        merge_tool_trust_exit_code=\"$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)\"\n-    fi\n+\tif ! test -z \"$merge_tool_cmd\"; then\n+\t\tmerge_tool_trust_exit_code=\"$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)\"\n+\tfi\n fi\n \n last_status=0\n rollup_status=0\n \n if test $# -eq 0 ; then\n-    files=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n-    if test -z \"$files\" ; then\n-\techo \"No files need merging\"\n-\texit 0\n-    fi\n-    echo Merging the files: \"$files\"\n-    git ls-files -u |\n-    sed -e 's/^[^\t]*\t//' |\n-    sort -u |\n-    while IFS= read i\n-    do\n-\tif test $last_status -ne 0; then\n-\t    prompt_after_failed_merge < /dev/tty || exit 1\n+\tfiles=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n+\tif test -z \"$files\" ; then\n+\t\techo \"No files need merging\"\n+\t\texit 0\n \tfi\n-\tprintf \"\\n\"\n-\tmerge_file \"$i\" < /dev/tty > /dev/tty\n-\tlast_status=$?\n-\tif test $last_status -ne 0; then\n-\t    rollup_status=1\n-\tfi\n-    done\n+\techo Merging the files: \"$files\"\n+\tgit ls-files -u |\n+\tsed -e 's/^[^\t]*\t//' |\n+\tsort -u |\n+\twhile IFS= read i\n+\tdo\n+\t\tif test $last_status -ne 0; then\n+\t\t\tprompt_after_failed_merge < /dev/tty || exit 1\n+\t\tfi\n+\t\tprintf \"\\n\"\n+\t\tmerge_file \"$i\" < /dev/tty > /dev/tty\n+\t\tlast_status=$?\n+\t\tif test $last_status -ne 0; then\n+\t\t\trollup_status=1\n+\t\tfi\n+\tdone\n else\n-    while test $# -gt 0; do\n-\tif test $last_status -ne 0; then\n-\t    prompt_after_failed_merge || exit 1\n-\tfi\n-\tprintf \"\\n\"\n-\tmerge_file \"$1\"\n-\tlast_status=$?\n-\tif test $last_status -ne 0; then\n-\t    rollup_status=1\n-\tfi\n-\tshift\n-    done\n+\twhile test $# -gt 0; do\n+\t\tif test $last_status -ne 0; then\n+\t\t\tprompt_after_failed_merge || exit 1\n+\t\tfi\n+\t\tprintf \"\\n\"\n+\t\tmerge_file \"$1\"\n+\t\tlast_status=$?\n+\t\tif test $last_status -ne 0; then\n+\t\t\trollup_status=1\n+\t\tfi\n+\t\tshift\n+\tdone\n fi\n \n exit $rollup_status\n-- \n1.6.1.3\n"},{"id":"109820","messageId":"1238389428-69328-3-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-2-git-send-email-davvid@gmail.com","subject":"[PATCH 2/8] mergetool: use $( ... ) instead of `backticks`","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:42Z","receivedAt":"2009-03-30T05:03:42Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This makes mergetool consistent with Documentation/CodingGuidelines.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex cfee28e..5ea126c 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -138,7 +138,7 @@ checkout_staged_file () {\n merge_file () {\n \tMERGED=\"$1\"\n \n-\tf=`git ls-files -u -- \"$MERGED\"`\n+\tf=$(git ls-files -u -- \"$MERGED\")\n \tif test -z \"$f\" ; then\n \t\tif test ! -f \"$MERGED\" ; then\n \t\t\techo \"$MERGED: file not found\"\n@@ -157,9 +157,9 @@ merge_file () {\n \tmv -- \"$MERGED\" \"$BACKUP\"\n \tcp -- \"$BACKUP\" \"$MERGED\"\n \n-\tbase_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n-\tlocal_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n-\tremote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n+\tbase_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}')\n+\tlocal_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}')\n+\tremote_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}')\n \n \tbase_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n \tlocal_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n@@ -322,7 +322,7 @@ do\n \t-t|--tool*)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t\tmerge_tool=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t\tmerge_tool=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\n \t\t\t;;\n \t\t1,*)\n \t\t\tusage ;;\n@@ -371,7 +371,7 @@ valid_tool() {\n }\n \n init_merge_tool_path() {\n-\tmerge_tool_path=`git config mergetool.$1.path`\n+\tmerge_tool_path=$(git config mergetool.$1.path)\n \tif test -z \"$merge_tool_path\" ; then\n \t\tcase \"$1\" in\n \t\t\temerge)\n@@ -401,7 +401,7 @@ prompt_after_failed_merge() {\n }\n \n if test -z \"$merge_tool\"; then\n-\tmerge_tool=`git config merge.tool`\n+\tmerge_tool=$(git config merge.tool)\n \tif test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n \t\techo >&2 \"git config option merge.tool set to unknown tool:\" \"$merge_tool\"\n \t\techo >&2 \"Resetting to default...\"\n@@ -461,7 +461,7 @@ last_status=0\n rollup_status=0\n \n if test $# -eq 0 ; then\n-\tfiles=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n+\tfiles=$(git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u)\n \tif test -z \"$files\" ; then\n \t\techo \"No files need merging\"\n \t\texit 0\n-- \n1.6.1.3\n"},{"id":"109824","messageId":"1238389428-69328-4-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-3-git-send-email-davvid@gmail.com","subject":"[PATCH 3/8] sh-tools: add a git-sh-tools shell helper script","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:43Z","receivedAt":"2009-03-30T05:03:43Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"git-sh-tools holds functions common to the git-*tool commands.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n .gitignore                     |    1 +\n Documentation/git-sh-tools.txt |   49 +++++++++++++++++++++++++++++++++++++++\n Makefile                       |    1 +\n command-list.txt               |    1 +\n git-sh-tools.sh                |   50 ++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 102 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/git-sh-tools.txt\n create mode 100644 git-sh-tools.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 966c886..cecf77e 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -114,6 +114,7 @@ git-rm\n git-send-email\n git-send-pack\n git-sh-setup\n+git-sh-tools\n git-shell\n git-shortlog\n git-show\ndiff --git a/Documentation/git-sh-tools.txt b/Documentation/git-sh-tools.txt\nnew file mode 100644\nindex 0000000..055a10c\n--- /dev/null\n+++ b/Documentation/git-sh-tools.txt\n@@ -0,0 +1,49 @@\n+git-sh-tool(1)\n+==============\n+\n+NAME\n+----\n+git-sh-tools - Common git *tool shell script functions\n+\n+SYNOPSIS\n+--------\n+'. \"$(git --exec-path)/git-sh-tools\"'\n+\n+DESCRIPTION\n+-----------\n+\n+This is not a command the end user would want to run.  Ever.\n+This documentation is meant for people who are studying the\n+Porcelain-ish scripts and/or are writing new ones.\n+\n+The 'git-sh-tools' scriptlet is designed to be sourced (using\n+`.`) by other shell scripts to set up some functions for\n+working with git merge/diff tools.\n+\n+Before sourcing it, your script should set up a few variables;\n+`TOOL_MODE` is used to define the operation mode for various\n+functions.  'diff' and 'merge' are valid values.\n+\n+FUNCTIONS\n+---------\n+valid_tool::\n+\tverifies that the specified merge tool is properly setup.\n+\n+valid_custom_tool::\n+\tverifies that a '(diff|merge)tool.<tool>.cmd' configuration exists.\n+\n+init_merge_tool_path::\n+\tsets up `$merge_tool_path` according to '(diff|merge)tool.<tool>.path'\n+\tconfigurations.\n+\n+Author\n+------\n+Written by David Aguilar <davvid@gmail.com>\n+\n+Documentation\n+--------------\n+Documentation by David Aguilar and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the linkgit:git[1] suite\ndiff --git a/Makefile b/Makefile\nindex d77fd71..3b7c20f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -292,6 +292,7 @@ SCRIPT_SH += git-rebase.sh\n SCRIPT_SH += git-repack.sh\n SCRIPT_SH += git-request-pull.sh\n SCRIPT_SH += git-sh-setup.sh\n+SCRIPT_SH += git-sh-tools.sh\n SCRIPT_SH += git-stash.sh\n SCRIPT_SH += git-submodule.sh\n SCRIPT_SH += git-web--browse.sh\ndiff --git a/command-list.txt b/command-list.txt\nindex fb03a2e..c3b6c87 100644\n--- a/command-list.txt\n+++ b/command-list.txt\n@@ -109,6 +109,7 @@ git-show-branch                         ancillaryinterrogators\n git-show-index                          plumbinginterrogators\n git-show-ref                            plumbinginterrogators\n git-sh-setup                            purehelpers\n+git-sh-tools                            purehelpers\n git-stash                               mainporcelain\n git-status                              mainporcelain common\n git-stripspace                          purehelpers\ndiff --git a/git-sh-tools.sh b/git-sh-tools.sh\nnew file mode 100644\nindex 0000000..234bac7\n--- /dev/null\n+++ b/git-sh-tools.sh\n@@ -0,0 +1,50 @@\n+# Verifies that the chosen merge tool is properly setup.\n+# Built-in merge tools are always valid.\n+valid_tool() {\n+\tcase \"$1\" in\n+\tkdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n+\t\t;; # happy\n+\t*)\n+\t\tif ! valid_custom_tool \"$1\"; then\n+\t\t\treturn 1\n+\t\tfi\n+\t\t;;\n+\tesac\n+}\n+\n+# Verifies that (difftool|mergetool).<tool>.cmd exists\n+# Requires $TOOL_MODE to be set.\n+valid_custom_tool() {\n+\tif test \"$TOOL_MODE\" = \"diff\"; then\n+\t\tmerge_tool_cmd=\"$(git config difftool.$1.cmd)\"\n+\t\ttest -z \"$merge_tool_cmd\" &&\n+\t\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n+\t\ttest -n \"$merge_tool_cmd\"\n+\telif test \"$TOOL_MODE\" = \"merge\"; then\n+\t\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n+\t\ttest -n \"$merge_tool_cmd\"\n+\tfi\n+}\n+\n+\n+# Set up $merge_tool_path for (diff|merge)tool.<tool>.path configurations\n+init_merge_tool_path() {\n+\tif test \"$TOOL_MODE\" = \"diff\"; then\n+\t\tmerge_tool_path=$(git config difftool.\"$1\".path)\n+\t\ttest -z \"$merge_tool_path\" &&\n+\t\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n+\telif test \"$TOOL_MODE\" = \"merge\"; then\n+\t\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n+\tfi\n+\n+\tif test -z \"$merge_tool_path\" ; then\n+\t\tcase \"$1\" in\n+\t\t\temerge)\n+\t\t\t\tmerge_tool_path=emacs\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmerge_tool_path=$1\n+\t\t\t\t;;\n+\t\tesac\n+\tfi\n+}\n-- \n1.6.1.3\n"},{"id":"109823","messageId":"1238389428-69328-5-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-4-git-send-email-davvid@gmail.com","subject":"[PATCH 4/8] mergetool: refactor git-mergetool to use git-sh-tools","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:44Z","receivedAt":"2009-03-30T05:03:44Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This removes the common valid_tool functions from git-mergetool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh |   35 ++---------------------------------\n 1 files changed, 2 insertions(+), 33 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 5ea126c..ec20030 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -11,7 +11,9 @@\n USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'\n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n+TOOL_MODE=merge\n . git-sh-setup\n+. git-sh-tools\n require_work_tree\n \n # Returns true if the mode reflects a symlink\n@@ -351,39 +353,6 @@ do\n \tshift\n done\n \n-valid_custom_tool()\n-{\n-\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n-\ttest -n \"$merge_tool_cmd\"\n-}\n-\n-valid_tool() {\n-\tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | \\\n-\t\temerge | vimdiff | gvimdiff | ecmerge)\n-\t\t\t;; # happy\n-\t\t*)\n-\t\t\tif ! valid_custom_tool \"$1\"; then\n-\t\t\t\treturn 1\n-\t\t\tfi\n-\t\t\t;;\n-\tesac\n-}\n-\n-init_merge_tool_path() {\n-\tmerge_tool_path=$(git config mergetool.$1.path)\n-\tif test -z \"$merge_tool_path\" ; then\n-\t\tcase \"$1\" in\n-\t\t\temerge)\n-\t\t\t\tmerge_tool_path=emacs\n-\t\t\t\t;;\n-\t\t\t*)\n-\t\t\t\tmerge_tool_path=$1\n-\t\t\t\t;;\n-\t\tesac\n-\tfi\n-}\n-\n prompt_after_failed_merge() {\n \twhile true; do\n \t\tprintf \"Continue merging other unresolved paths (y/n) ? \"\n-- \n1.6.1.3\n"},{"id":"109821","messageId":"1238389428-69328-6-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-5-git-send-email-davvid@gmail.com","subject":"[PATCH 5/8] difftool: refactor git-difftool to use git-sh-tools","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:45Z","receivedAt":"2009-03-30T05:03:45Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This removes the common valid_tool functions from git-difftool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool-helper.sh |   45 +++------------------------------------------\n 1 files changed, 3 insertions(+), 42 deletions(-)\n\ndiff --git a/git-difftool-helper.sh b/git-difftool-helper.sh\nindex 02bb135..2051a35 100755\n--- a/git-difftool-helper.sh\n+++ b/git-difftool-helper.sh\n@@ -7,6 +7,9 @@\n #\n # Copyright (c) 2009 David Aguilar\n \n+TOOL_MODE=diff\n+. git-sh-tools\n+\n # difftool.prompt controls the default prompt/no-prompt behavior\n # and is overridden with $GIT_DIFFTOOL*_PROMPT.\n should_prompt () {\n@@ -102,48 +105,6 @@ launch_merge_tool () {\n \tesac\n }\n \n-# Verifies that (difftool|mergetool).<tool>.cmd exists\n-valid_custom_tool() {\n-\tmerge_tool_cmd=\"$(git config difftool.$1.cmd)\"\n-\ttest -z \"$merge_tool_cmd\" &&\n-\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n-\ttest -n \"$merge_tool_cmd\"\n-}\n-\n-# Verifies that the chosen merge tool is properly setup.\n-# Built-in merge tools are always valid.\n-valid_tool() {\n-\tcase \"$1\" in\n-\tkdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n-\t\t;; # happy\n-\t*)\n-\t\tif ! valid_custom_tool \"$1\"\n-\t\tthen\n-\t\t\treturn 1\n-\t\tfi\n-\t\t;;\n-\tesac\n-}\n-\n-# Sets up the merge_tool_path variable.\n-# This handles the difftool.<tool>.path configuration.\n-# This also falls back to mergetool defaults.\n-init_merge_tool_path() {\n-\tmerge_tool_path=$(git config difftool.\"$1\".path)\n-\ttest -z \"$merge_tool_path\" &&\n-\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n-\tif test -z \"$merge_tool_path\"; then\n-\t\tcase \"$1\" in\n-\t\temerge)\n-\t\t\tmerge_tool_path=emacs\n-\t\t\t;;\n-\t\t*)\n-\t\t\tmerge_tool_path=\"$1\"\n-\t\t\t;;\n-\t\tesac\n-\tfi\n-}\n-\n # Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values\n test -n \"$GIT_MERGE_TOOL\" && merge_tool=\"$GIT_MERGE_TOOL\"\n test -n \"$GIT_DIFF_TOOL\" && merge_tool=\"$GIT_DIFF_TOOL\"\n-- \n1.6.1.3\n"},{"id":"109822","messageId":"1238389428-69328-7-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-6-git-send-email-davvid@gmail.com","subject":"[PATCH 6/8] sh-tools: add a run_merge_tool function","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:46Z","receivedAt":"2009-03-30T05:03:46Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This function launches merge tools and will be used to refactor\ngit-(diff|merge)tool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/git-sh-tools.txt |    3 +\n git-sh-tools.sh                |  147 +++++++++++++++++++++++++++++++++++++--\n 2 files changed, 142 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-sh-tools.txt b/Documentation/git-sh-tools.txt\nindex 055a10c..68d1b37 100644\n--- a/Documentation/git-sh-tools.txt\n+++ b/Documentation/git-sh-tools.txt\n@@ -36,6 +36,9 @@ init_merge_tool_path::\n \tsets up `$merge_tool_path` according to '(diff|merge)tool.<tool>.path'\n \tconfigurations.\n \n+run_merge_tool::\n+\truns the specified merge tool.\n+\n Author\n ------\n Written by David Aguilar <davvid@gmail.com>\ndiff --git a/git-sh-tools.sh b/git-sh-tools.sh\nindex 234bac7..5c7bd18 100644\n--- a/git-sh-tools.sh\n+++ b/git-sh-tools.sh\n@@ -12,29 +12,34 @@ valid_tool() {\n \tesac\n }\n \n+# Test whether we're in merge mode\n+mergetool_mode()\n+{\n+\ttest \"$TOOL_MODE\" = \"merge\"\n+}\n+\n # Verifies that (difftool|mergetool).<tool>.cmd exists\n # Requires $TOOL_MODE to be set.\n valid_custom_tool() {\n-\tif test \"$TOOL_MODE\" = \"diff\"; then\n-\t\tmerge_tool_cmd=\"$(git config difftool.$1.cmd)\"\n-\t\ttest -z \"$merge_tool_cmd\" &&\n+\tif mergetool_mode; then\n \t\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n \t\ttest -n \"$merge_tool_cmd\"\n-\telif test \"$TOOL_MODE\" = \"merge\"; then\n+\telse\n+\t\tmerge_tool_cmd=\"$(git config difftool.$1.cmd)\"\n+\t\ttest -z \"$merge_tool_cmd\" &&\n \t\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n \t\ttest -n \"$merge_tool_cmd\"\n \tfi\n }\n \n-\n # Set up $merge_tool_path for (diff|merge)tool.<tool>.path configurations\n init_merge_tool_path() {\n-\tif test \"$TOOL_MODE\" = \"diff\"; then\n+\tif mergetool_mode; then\n+\t\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n+\telse\n \t\tmerge_tool_path=$(git config difftool.\"$1\".path)\n \t\ttest -z \"$merge_tool_path\" &&\n \t\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n-\telif test \"$TOOL_MODE\" = \"merge\"; then\n-\t\tmerge_tool_path=$(git config mergetool.\"$1\".path)\n \tfi\n \n \tif test -z \"$merge_tool_path\" ; then\n@@ -48,3 +53,129 @@ init_merge_tool_path() {\n \t\tesac\n \tfi\n }\n+\n+# Runs a side-by-side merge tool\n+run_merge_tool()\n+{\n+\tmerge_tool=\"$1\"\n+\n+\t# base_present is always false when !mergetool_mode\n+\tcase \"$merge_tool\" in\n+\tkdiff3)\n+\t\tif mergetool_mode; then\n+\t\t\tbase=Baes\n+\t\t\tlocal=Local\n+\t\t\tremote=Remote\n+\t\telse\n+\t\t\tbase=A\n+\t\t\tlocal=A\n+\t\t\tremote=B\n+\t\tfi\n+\t\tif base_present; then\n+\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t--L1 \"$MERGED ($base)\" \\\n+\t\t\t\t--L2 \"$MERGED ($local)\" \\\n+\t\t\t\t--L3 \"$MERGED ($remote)\" \\\n+\t\t\t\t-o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t > /dev/null 2>&1)\n+\t\telse\n+\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t--L1 \"$MERGED ($local)\" \\\n+\t\t\t\t--L2 \"$MERGED ($remote)\" \\\n+\t\t\t\t-o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t > /dev/null 2>&1)\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\ttkdiff)\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\tmeld)\n+\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\tvimdiff)\n+\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\tgvimdiff)\n+\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\txxdiff)\n+\t\tif mergetool_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\txtra_args='--show-merged-pane'\n+\t\telse\n+\t\t\txtra_args=\n+\t\tfi\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" -X $xtra_args \\\n+\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -X $xtra_args \\\n+\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\topendiff)\n+\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t-ancestor \"$BASE\" -merge \"$MERGED\" | cat\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t-merge \"$MERGED\" | cat\n+\t\tfi\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\tecmerge)\n+\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\tif base_present; then\n+\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge3 --to=\"$MERGED\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n+\t\tfi\n+\t\tmergetool_mode && check_unchanged\n+\t\t;;\n+\temerge)\n+\t\tif base_present ; then\n+\t\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$MERGED\")\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -f emerge-files-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\t*)\n+\t\tif test -n \"$merge_tool_cmd\"; then\n+\t\t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n+\t\t\t\tmergetool_mode && touch \"$BACKUP\"\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tmergetool_mode && check_unchanged\n+\t\t\telse\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tstatus=$?\n+\t\t\tfi\n+\t\tfi\n+\t\t;;\n+\tesac\n+\treturn $status\n+}\n-- \n1.6.1.3\n"},{"id":"109826","messageId":"1238389428-69328-8-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-7-git-send-email-davvid@gmail.com","subject":"[PATCH 7/8] mergetool: refactor git-mergetool to use run_merge_tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:47Z","receivedAt":"2009-03-30T05:03:47Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This removes most of the duplicated code in git-mergetool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh |  106 ++----------------------------------------------------\n 1 files changed, 3 insertions(+), 103 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex ec20030..0f5033c 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -191,109 +191,9 @@ merge_file () {\n \t\tread ans\n \tfi\n \n-\tcase \"$merge_tool\" in\n-\tkdiff3)\n-\t\tif base_present ; then\n-\t\t\t(\"$merge_tool_path\" --auto \\\n-\t\t\t\t--L1 \"$MERGED (Base)\" \\\n-\t\t\t\t--L2 \"$MERGED (Local)\" \\\n-\t\t\t\t--L3 \"$MERGED (Remote)\" \\\n-\t\t\t\t-o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t > /dev/null 2>&1)\n-\t\telse\n-\t\t\t(\"$merge_tool_path\" --auto \\\n-\t\t\t\t--L1 \"$MERGED (Local)\" \\\n-\t\t\t\t--L2 \"$MERGED (Remote)\" \\\n-\t\t\t\t-o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t > /dev/null 2>&1)\n-\t\tfi\n-\t\tstatus=$?\n-\t\t;;\n-\ttkdiff)\n-\t\tif base_present ; then\n-\t\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t\telse\n-\t\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t\tfi\n-\t\tstatus=$?\n-\t\t;;\n-\tmeld)\n-\t\ttouch \"$BACKUP\"\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t\tcheck_unchanged\n-\t\t;;\n-\tvimdiff)\n-\t\ttouch \"$BACKUP\"\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t\tcheck_unchanged\n-\t\t;;\n-\tgvimdiff)\n-\t\ttouch \"$BACKUP\"\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t\tcheck_unchanged\n-\t\t;;\n-\txxdiff)\n-\t\ttouch \"$BACKUP\"\n-\t\tif base_present ; then\n-\t\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n-\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n-\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n-\t\telse\n-\t\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n-\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n-\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t\tfi\n-\t\tcheck_unchanged\n-\t\t;;\n-\topendiff)\n-\t\ttouch \"$BACKUP\"\n-\t\tif base_present; then\n-\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t\t-ancestor \"$BASE\" -merge \"$MERGED\" | cat\n-\t\telse\n-\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t\t-merge \"$MERGED\" | cat\n-\t\tfi\n-\t\tcheck_unchanged\n-\t\t;;\n-\tecmerge)\n-\t\ttouch \"$BACKUP\"\n-\t\tif base_present; then\n-\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t\t--default --mode=merge3 --to=\"$MERGED\"\n-\t\telse\n-\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n-\t\tfi\n-\t\tcheck_unchanged\n-\t\t;;\n-\temerge)\n-\t\tif base_present ; then\n-\t\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \\\n-\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$MERGED\")\"\n-\t\telse\n-\t\t\t\"$merge_tool_path\" -f emerge-files-command \\\n-\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n-\t\tfi\n-\t\tstatus=$?\n-\t\t;;\n-\t*)\n-\t\tif test -n \"$merge_tool_cmd\"; then\n-\t\t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n-\t\t\t\ttouch \"$BACKUP\"\n-\t\t\t\t( eval $merge_tool_cmd )\n-\t\t\t\tcheck_unchanged\n-\t\t\telse\n-\t\t\t\t( eval $merge_tool_cmd )\n-\t\t\t\tstatus=$?\n-\t\t\tfi\n-\t\tfi\n-\t\t;;\n-\tesac\n+\trun_merge_tool \"$merge_tool\"\n+\tstatus=$?\n+\n \tif test \"$status\" -ne 0; then\n \t\techo \"merge of $MERGED failed\" 1>&2\n \t\tmv -- \"$BACKUP\" \"$MERGED\"\n-- \n1.6.1.3\n"},{"id":"109827","messageId":"1238389428-69328-9-git-send-email-davvid@gmail.com","threadId":"18630","inReplyTo":"1238389428-69328-8-git-send-email-davvid@gmail.com","subject":"[PATCH 8/8] difftool: refactor git-difftool-helper to use run_merge_tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T05:03:48Z","receivedAt":"2009-03-30T05:03:48Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This removes most of the duplicated code in git-difftool-helper.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool-helper.sh |   67 ++++-------------------------------------------\n 1 files changed, 6 insertions(+), 61 deletions(-)\n\ndiff --git a/git-difftool-helper.sh b/git-difftool-helper.sh\nindex 2051a35..d90277b 100755\n--- a/git-difftool-helper.sh\n+++ b/git-difftool-helper.sh\n@@ -10,6 +10,11 @@\n TOOL_MODE=diff\n . git-sh-tools\n \n+base_present()\n+{\n+\treturn 1\n+}\n+\n # difftool.prompt controls the default prompt/no-prompt behavior\n # and is overridden with $GIT_DIFFTOOL*_PROMPT.\n should_prompt () {\n@@ -42,67 +47,7 @@ launch_merge_tool () {\n \tfi\n \n \t# Run the appropriate merge tool command\n-\tcase \"$merge_tool\" in\n-\tkdiff3)\n-\t\tbasename=$(basename \"$MERGED\")\n-\t\t\"$merge_tool_path\" --auto \\\n-\t\t\t--L1 \"$basename (A)\" \\\n-\t\t\t--L2 \"$basename (B)\" \\\n-\t\t\t-o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t> /dev/null 2>&1\n-\t\t;;\n-\n-\tkompare)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\ttkdiff)\n-\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tmeld)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tvimdiff)\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tgvimdiff)\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\txxdiff)\n-\t\t\"$merge_tool_path\" \\\n-\t\t\t-X \\\n-\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n-\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t\t--merged-file \"$MERGED\" \\\n-\t\t\t\"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\topendiff)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t-merge \"$MERGED\" | cat\n-\t\t;;\n-\n-\tecmerge)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n-\t\t;;\n-\n-\temerge)\n-\t\t\"$merge_tool_path\" -f emerge-files-command \\\n-\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n-\t\t;;\n-\n-\t*)\n-\t\tif test -n \"$merge_tool_cmd\"; then\n-\t\t\t( eval $merge_tool_cmd )\n-\t\tfi\n-\t\t;;\n-\tesac\n+\trun_merge_tool \"$merge_tool\"\n }\n \n # Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values\n-- \n1.6.1.3\n"},{"id":"109841","messageId":"200903300855.09353.markus.heidelberg@web.de","threadId":"18630","inReplyTo":"1238389428-69328-7-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 6/8] sh-tools: add a run_merge_tool function","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-03-30T06:55:09Z","receivedAt":"2009-03-30T06:55:09Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"David Aguilar, 30.03.2009:\n> +\t\tif mergetool_mode; then\n> +\t\t\tbase=Baes\n\nBase\n\n> +\t\t\tlocal=Local\n> +\t\t\tremote=Remote\n> +\t\telse\n"},{"id":"109844","messageId":"200903300902.28821.markus.heidelberg@web.de","threadId":"18630","inReplyTo":"1238389428-69328-1-git-send-email-davvid@gmail.com","subject":"Re:","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-03-30T07:02:28Z","receivedAt":"2009-03-30T07:02:28Z","isPatch":false,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"David Aguilar, 30.03.2009:\n> This is based on top of Junio's \"pu\" branch and is a\n> continuation of the recent difftool series.\n\nFor everyone who wants to apply the patch series: Patch 5/8 depends on\nthis:\n  [PATCH v2] difftool: add support for a difftool.prompt config variable\nsent about 8 minutes before this series.\n\nMarkus\n"},{"id":"109846","messageId":"200903300932.29870.markus.heidelberg@web.de","threadId":"18630","inReplyTo":"1238389428-69328-7-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 6/8] sh-tools: add a run_merge_tool function","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-03-30T07:32:29Z","receivedAt":"2009-03-30T07:32:29Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"David Aguilar, 30.03.2009:\n> +# Runs a side-by-side merge tool\n> +run_merge_tool()\n> +{\n> +\tmerge_tool=\"$1\"\n> +\n> +\t# base_present is always false when !mergetool_mode\n> +\tcase \"$merge_tool\" in\n> +\tkdiff3)\n> [...]\n\nKompare is missing here. Note, that this is only diff tool, not for\nmerges.\n\nMarkus\n"},{"id":"109847","messageId":"20090330074625.GA11769@gmail.com","threadId":"18630","inReplyTo":"200903300932.29870.markus.heidelberg@web.de","subject":"Re: [PATCH 6/8] sh-tools: add a run_merge_tool function","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T07:46:26Z","receivedAt":"2009-03-30T07:46:26Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On  0, Markus Heidelberg <markus.heidelberg@web.de> wrote:\n> David Aguilar, 30.03.2009:\n> > +# Runs a side-by-side merge tool\n> > +run_merge_tool()\n> > +{\n> > +\tmerge_tool=\"$1\"\n> > +\n> > +\t# base_present is always false when !mergetool_mode\n> > +\tcase \"$merge_tool\" in\n> > +\tkdiff3)\n> > [...]\n> \n> Kompare is missing here. Note, that this is only diff tool, not for\n> merges.\n> \n> Markus\n> \n\nThanks, will fixup asap.\nI botched the --cover letter too ;)\nnote to self: no more refactoring while sleepy on plane.\n\n-- \n\n\tDavid\n"},{"id":"109856","messageId":"7vzlf3flim.fsf@gitster.siamese.dyndns.org","threadId":"18630","inReplyTo":"1238389428-69328-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 1/8] mergetool: use tabs consistently","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-30T08:44:01Z","receivedAt":"2009-03-30T08:44:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n\nEven though this [1/8] is obviously regression free, and I think the\noverall direction in which the series is going is good, I'll wait until I\nhear Acks from Charles Bailey for the parts that involve mergetool.  I do\nnot use either mergetool nor difftool myself, and going over every single\nline of this series to spot potential regression is beyond my bandwidth\nright now.\n\nI do not think bits only common between mergetool and difftool should be\ncalled with a very generic name \"sh-tools\".  We didn't call the result of\na similar refactoring for launching web browser from help and instaweb\ncontext with such a generic name (it is called git-web--browse).\n"},{"id":"109857","messageId":"7vvdprflet.fsf@gitster.siamese.dyndns.org","threadId":"18630","inReplyTo":"200903300902.28821.markus.heidelberg@web.de","subject":"Re:","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-30T08:46:18Z","receivedAt":"2009-03-30T08:46:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Markus Heidelberg <markus.heidelberg@web.de> writes:\n\n> David Aguilar, 30.03.2009:\n>> This is based on top of Junio's \"pu\" branch and is a\n>> continuation of the recent difftool series.\n>\n> For everyone who wants to apply the patch series: Patch 5/8 depends on\n> this:\n>   [PATCH v2] difftool: add support for a difftool.prompt config variable\n> sent about 8 minutes before this series.\n\nThanks for keeping an eye on this series, as a recent contributor to\nmergetool.  I do not use mergetool myself, but this refactoring seems to\nbe a good idea in general, and help in reviewing the series is very much\nappreciated.\n"},{"id":"109867","messageId":"20090330092226.GB18953@gmail.com","threadId":"18630","inReplyTo":"7vzlf3flim.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/8] mergetool: use tabs consistently","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-30T09:22:27Z","receivedAt":"2009-03-30T09:22:27Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On  0, Junio C Hamano <gitster@pobox.com> wrote:\n> Thanks.\n> \n> Even though this [1/8] is obviously regression free, and I think the\n> overall direction in which the series is going is good, I'll wait until I\n> hear Acks from Charles Bailey for the parts that involve mergetool.  I do\n> not use either mergetool nor difftool myself, and going over every single\n> line of this series to spot potential regression is beyond my bandwidth\n> right now.\n> \n> I do not think bits only common between mergetool and difftool should be\n> called with a very generic name \"sh-tools\".  We didn't call the result of\n> a similar refactoring for launching web browser from help and instaweb\n> context with such a generic name (it is called git-web--browse).\n\nI also felt iffy about the name.\nMaybe...\n\tgit-interactive--tools ?\n\tgit-merge-diff--tools ?\n\tgit-mergetool--lib ?\n\t(i'm pretty bad with this naming stuff ;))\n\n(I have --interactive on my brain thanks to Ping's patch ;))\n\nI can rebase as needed once we get more feedback, particularly\nnotes from Charles.\n\n-- \n\n\tDavid\n"},{"id":"109942","messageId":"20090330213530.GA7091@hashpling.org","threadId":"18630","inReplyTo":"7vzlf3flim.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/8] mergetool: use tabs consistently","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-03-30T21:35:30Z","receivedAt":"2009-03-30T21:35:30Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Mon, Mar 30, 2009 at 01:44:01AM -0700, Junio C Hamano wrote:\n> Thanks.\n> \n> Even though this [1/8] is obviously regression free, and I think the\n> overall direction in which the series is going is good, I'll wait until I\n> hear Acks from Charles Bailey for the parts that involve mergetool.  I do\n> not use either mergetool nor difftool myself, and going over every single\n> line of this series to spot potential regression is beyond my bandwidth\n> right now.\n> \n> I do not think bits only common between mergetool and difftool should be\n> called with a very generic name \"sh-tools\".  We didn't call the result of\n> a similar refactoring for launching web browser from help and instaweb\n> context with such a generic name (it is called git-web--browse).\n\nOK, I've just had a very quick review of the patch series and, in\ngeneral, I like it.\n\nI don't much like [1/8] though. I'm all in favour of consistency, but\nthis patch touches most of the lines in git-mergetool and tries to go\nthe opposite way to the consistency drive that we were trying to\nintroduce gradually (i.e. only through lines materially affected by\nsubsequent patches) in:\n\ncommit 0eea345111a9b9fea4dd2841b80bc7d62964e812\nAuthor: Charles Bailey <charles@hashpling.org>\nDate:   Thu Nov 13 12:41:13 2008 +0000\n\n    Fix some tab/space inconsistencies in git-mergetool.sh\n\nIf you'd gone the other way the patch to consistency would only affect\n23 lines rather than 347 lines and all bar 3 of these lines you\nsubsequently remove from git-mergetool.sh in later patches anyway.\n\n[2/8] - looks good.\n\n[3/8] - no mergetool impact.\n\n[4/8] - Hmmm, OK. Even so at this point, I'm getting slightly iffy\nfeelings about the whole init_merge_tool_path sets a variable needed\nby the calling script. I know it's only scripting and not programming,\nbut it seemed less bad to set (global) variables in sh functions when\nthey were all in the same sh script.\n\n[5/8] - no mergtool impact.\n\n[6/8] - ditto\n\n[7/8] - OK, here's where my uneasiness about global script variables\nvs. parameters really gets going. Why is merge_tool a parameter when\nit's setup once and doesn't change in the invocation of a script, yet\nbase_present is a script global but can vary between sets of paths to\nbe merged?\n\nI fully appreciate that this is just inheriting the way things are\nand that they weren't beautiful before, but it somehow seems even\nworse when the variables are set in one script and used from a\nfunction in a separate sourced script. We're definitely setting up a\nvery strong coupling between the two scripts which will make it harder\nto change either in the future.\n\n[8/8] - no mergetool impact here.\n\nOn the plus side, I really like the introduction and function of the\nrun_mergetool function. It's exactly the split that will make\nextending mergetool resolves of file vs. symlink vs. directory easier\nin the future. I have a similar split in some slow brewing patches\nmyself.\n\nI think that [1/8] is the only patch that I'd relucatant to ack, as it\nseems like unnecessary churn and change of direction. Here's a sample\npatch for consistency 'the other way'. As I mentioned before, the\nfirst to hunks are made redundant by your subsequent changes anyway,\nso I only counted 3 lines that are currently inconsistent in\ngit-mergetool as it stands at the moment.\n\nSample patch fixing consistent whitespace 'the other way'.\n---\n git-mergetool.sh |   46 +++++++++++++++++++++++-----------------------\n 1 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 87fa88a..1588b5f 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -344,29 +344,29 @@ valid_custom_tool()\n }\n \n valid_tool() {\n-\tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n-\t\t\t;; # happy\n-\t\t*)\n-\t\t\tif ! valid_custom_tool \"$1\"; then\n-\t\t\t\treturn 1\n-\t\t\tfi\n-\t\t\t;;\n-\tesac\n+    case \"$1\" in\n+\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n+\t    ;; # happy\n+\t*)\n+\t    if ! valid_custom_tool \"$1\"; then\n+\t\treturn 1\n+\t    fi\n+\t    ;;\n+    esac\n }\n \n init_merge_tool_path() {\n-\tmerge_tool_path=`git config mergetool.$1.path`\n-\tif test -z \"$merge_tool_path\" ; then\n-\t\tcase \"$1\" in\n-\t\t\temerge)\n-\t\t\t\tmerge_tool_path=emacs\n-\t\t\t\t;;\n-\t\t\t*)\n-\t\t\t\tmerge_tool_path=$1\n-\t\t\t\t;;\n-\t\tesac\n-\tfi\n+    merge_tool_path=`git config mergetool.$1.path`\n+    if test -z \"$merge_tool_path\" ; then\n+\tcase \"$1\" in\n+\t    emerge)\n+\t\tmerge_tool_path=emacs\n+\t\t;;\n+\t    *)\n+\t\tmerge_tool_path=$1\n+\t\t;;\n+\tesac\n+    fi\n }\n \n prompt_after_failed_merge() {\n@@ -389,9 +389,9 @@ prompt_after_failed_merge() {\n if test -z \"$merge_tool\"; then\n     merge_tool=`git config merge.tool`\n     if test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n-\t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n-\t    echo >&2 \"Resetting to default...\"\n-\t    unset merge_tool\n+\techo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n+\techo >&2 \"Resetting to default...\"\n+\tunset merge_tool\n     fi\n fi\n \n-- \n1.6.2.323.geaf6e\n\n-- \nCharles Bailey\nhttp://ccgi.hashpling.plus.com/blog/\n"},{"id":"109975","messageId":"20090331063613.GA20690@gmail.com","threadId":"18630","inReplyTo":"20090330213530.GA7091@hashpling.org","subject":"Re: [PATCH 1/8] mergetool: use tabs consistently","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-31T06:36:14Z","receivedAt":"2009-03-31T06:36:14Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On  0, Charles Bailey <charles@hashpling.org> wrote:\n> On Mon, Mar 30, 2009 at 01:44:01AM -0700, Junio C Hamano wrote:\n> \n> I don't much like [1/8] though. I'm all in favour of consistency, but\n> this patch touches most of the lines in git-mergetool and tries to go\n> the opposite way to the consistency drive that we were trying to\n> introduce gradually (i.e. only through lines materially affected by\n> subsequent patches) in:\n\nSounds good.  I'll re-roll and give the refactoring another go.\n\nI think we can definitely do better, and more importantly, I\nthink we can decouple things by using less globals.\n\nJunio, did you have any comments about patch v2\n\"difftool: add support for difftool.prompt config variable\"?\n\nThis series was based on top of that patch so I'm wondering if I\nshould do that again.\n\n\n> \n> commit 0eea345111a9b9fea4dd2841b80bc7d62964e812\n> Author: Charles Bailey <charles@hashpling.org>\n> Date:   Thu Nov 13 12:41:13 2008 +0000\n> \n>     Fix some tab/space inconsistencies in git-mergetool.sh\n> \n> If you'd gone the other way the patch to consistency would only affect\n> 23 lines rather than 347 lines and all bar 3 of these lines you\n> subsequently remove from git-mergetool.sh in later patches anyway.\n> \n> [2/8] - looks good.\n> \n> [3/8] - no mergetool impact.\n> \n> [4/8] - Hmmm, OK. Even so at this point, I'm getting slightly iffy\n> feelings about the whole init_merge_tool_path sets a variable needed\n> by the calling script. I know it's only scripting and not programming,\n> but it seemed less bad to set (global) variables in sh functions when\n> they were all in the same sh script.\n> \n> [5/8] - no mergtool impact.\n> \n> [6/8] - ditto\n> \n> [7/8] - OK, here's where my uneasiness about global script variables\n> vs. parameters really gets going. Why is merge_tool a parameter when\n> it's setup once and doesn't change in the invocation of a script, yet\n> base_present is a script global but can vary between sets of paths to\n> be merged?\n> \n> I fully appreciate that this is just inheriting the way things are\n> and that they weren't beautiful before, but it somehow seems even\n> worse when the variables are set in one script and used from a\n> function in a separate sourced script. We're definitely setting up a\n> very strong coupling between the two scripts which will make it harder\n> to change either in the future.\n> \n> [8/8] - no mergetool impact here.\n> \n> On the plus side, I really like the introduction and function of the\n> run_mergetool function. It's exactly the split that will make\n> extending mergetool resolves of file vs. symlink vs. directory easier\n> in the future. I have a similar split in some slow brewing patches\n> myself.\n> \n> I think that [1/8] is the only patch that I'd relucatant to ack, as it\n> seems like unnecessary churn and change of direction. Here's a sample\n> patch for consistency 'the other way'. As I mentioned before, the\n> first to hunks are made redundant by your subsequent changes anyway,\n> so I only counted 3 lines that are currently inconsistent in\n> git-mergetool as it stands at the moment.\n> \n> Sample patch fixing consistent whitespace 'the other way'.\n> ---\n>  git-mergetool.sh |   46 +++++++++++++++++++++++-----------------------\n>  1 files changed, 23 insertions(+), 23 deletions(-)\n> \n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index 87fa88a..1588b5f 100755\n> --- a/git-mergetool.sh\n> +++ b/git-mergetool.sh\n> @@ -344,29 +344,29 @@ valid_custom_tool()\n>  }\n>  \n>  valid_tool() {\n> -\tcase \"$1\" in\n> -\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n> -\t\t\t;; # happy\n> -\t\t*)\n> -\t\t\tif ! valid_custom_tool \"$1\"; then\n> -\t\t\t\treturn 1\n> -\t\t\tfi\n> -\t\t\t;;\n> -\tesac\n> +    case \"$1\" in\n> +\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n> +\t    ;; # happy\n> +\t*)\n> +\t    if ! valid_custom_tool \"$1\"; then\n> +\t\treturn 1\n> +\t    fi\n> +\t    ;;\n> +    esac\n>  }\n>  \n>  init_merge_tool_path() {\n> -\tmerge_tool_path=`git config mergetool.$1.path`\n> -\tif test -z \"$merge_tool_path\" ; then\n> -\t\tcase \"$1\" in\n> -\t\t\temerge)\n> -\t\t\t\tmerge_tool_path=emacs\n> -\t\t\t\t;;\n> -\t\t\t*)\n> -\t\t\t\tmerge_tool_path=$1\n> -\t\t\t\t;;\n> -\t\tesac\n> -\tfi\n> +    merge_tool_path=`git config mergetool.$1.path`\n> +    if test -z \"$merge_tool_path\" ; then\n> +\tcase \"$1\" in\n> +\t    emerge)\n> +\t\tmerge_tool_path=emacs\n> +\t\t;;\n> +\t    *)\n> +\t\tmerge_tool_path=$1\n> +\t\t;;\n> +\tesac\n> +    fi\n>  }\n>  \n>  prompt_after_failed_merge() {\n> @@ -389,9 +389,9 @@ prompt_after_failed_merge() {\n>  if test -z \"$merge_tool\"; then\n>      merge_tool=`git config merge.tool`\n>      if test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n> -\t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n> -\t    echo >&2 \"Resetting to default...\"\n> -\t    unset merge_tool\n> +\techo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n> +\techo >&2 \"Resetting to default...\"\n> +\tunset merge_tool\n>      fi\n>  fi\n>  \n> -- \n> 1.6.2.323.geaf6e\n> \n> -- \n> Charles Bailey\n> http://ccgi.hashpling.plus.com/blog/\n\n-- \n\t\tDavid\n"},{"id":"110157","messageId":"7vab70z29b.fsf@gitster.siamese.dyndns.org","threadId":"18630","inReplyTo":"20090331063613.GA20690@gmail.com","subject":"Re: [PATCH 1/8] mergetool: use tabs consistently","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-01T17:56:32Z","receivedAt":"2009-04-01T17:56:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> On  0, Charles Bailey <charles@hashpling.org> wrote:\n>> On Mon, Mar 30, 2009 at 01:44:01AM -0700, Junio C Hamano wrote:\n>> \n>> I don't much like [1/8] though. I'm all in favour of consistency, but\n>> this patch touches most of the lines in git-mergetool and tries to go\n>> the opposite way to the consistency drive that we were trying to\n>> introduce gradually (i.e. only through lines materially affected by\n>> subsequent patches) in:\n>\n> Sounds good.  I'll re-roll and give the refactoring another go.\n>\n> I think we can definitely do better, and more importantly, I\n> think we can decouple things by using less globals.\n>\n> Junio, did you have any comments about patch v2\n> \"difftool: add support for difftool.prompt config variable\"?\n\nI only took a cursory look but it; you did seem to have based it on the\none I queued in 'pu' with a typo-fixup and it looked fine.\n\nThanks.\n"}]}