git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Charles Bailey <charles@hashpling.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/8] mergetool: use tabs consistently
Date: Mon, 30 Mar 2009 23:36:14 -0700	[thread overview]
Message-ID: <20090331063613.GA20690@gmail.com> (raw)
In-Reply-To: <20090330213530.GA7091@hashpling.org>

On  0, Charles Bailey <charles@hashpling.org> wrote:
> On Mon, Mar 30, 2009 at 01:44:01AM -0700, Junio C Hamano wrote:
> 
> I don't much like [1/8] though. I'm all in favour of consistency, but
> this patch touches most of the lines in git-mergetool and tries to go
> the opposite way to the consistency drive that we were trying to
> introduce gradually (i.e. only through lines materially affected by
> subsequent patches) in:

Sounds good.  I'll re-roll and give the refactoring another go.

I think we can definitely do better, and more importantly, I
think we can decouple things by using less globals.

Junio, did you have any comments about patch v2
"difftool: add support for difftool.prompt config variable"?

This series was based on top of that patch so I'm wondering if I
should do that again.


> 
> commit 0eea345111a9b9fea4dd2841b80bc7d62964e812
> Author: Charles Bailey <charles@hashpling.org>
> Date:   Thu Nov 13 12:41:13 2008 +0000
> 
>     Fix some tab/space inconsistencies in git-mergetool.sh
> 
> If you'd gone the other way the patch to consistency would only affect
> 23 lines rather than 347 lines and all bar 3 of these lines you
> subsequently remove from git-mergetool.sh in later patches anyway.
> 
> [2/8] - looks good.
> 
> [3/8] - no mergetool impact.
> 
> [4/8] - Hmmm, OK. Even so at this point, I'm getting slightly iffy
> feelings about the whole init_merge_tool_path sets a variable needed
> by the calling script. I know it's only scripting and not programming,
> but it seemed less bad to set (global) variables in sh functions when
> they were all in the same sh script.
> 
> [5/8] - no mergtool impact.
> 
> [6/8] - ditto
> 
> [7/8] - OK, here's where my uneasiness about global script variables
> vs. parameters really gets going. Why is merge_tool a parameter when
> it's setup once and doesn't change in the invocation of a script, yet
> base_present is a script global but can vary between sets of paths to
> be merged?
> 
> I fully appreciate that this is just inheriting the way things are
> and that they weren't beautiful before, but it somehow seems even
> worse when the variables are set in one script and used from a
> function in a separate sourced script. We're definitely setting up a
> very strong coupling between the two scripts which will make it harder
> to change either in the future.
> 
> [8/8] - no mergetool impact here.
> 
> On the plus side, I really like the introduction and function of the
> run_mergetool function. It's exactly the split that will make
> extending mergetool resolves of file vs. symlink vs. directory easier
> in the future. I have a similar split in some slow brewing patches
> myself.
> 
> I think that [1/8] is the only patch that I'd relucatant to ack, as it
> seems like unnecessary churn and change of direction. Here's a sample
> patch for consistency 'the other way'. As I mentioned before, the
> first to hunks are made redundant by your subsequent changes anyway,
> so I only counted 3 lines that are currently inconsistent in
> git-mergetool as it stands at the moment.
> 
> Sample patch fixing consistent whitespace 'the other way'.
> ---
>  git-mergetool.sh |   46 +++++++++++++++++++++++-----------------------
>  1 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 87fa88a..1588b5f 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -344,29 +344,29 @@ valid_custom_tool()
>  }
>  
>  valid_tool() {
> -	case "$1" in
> -		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
> -			;; # happy
> -		*)
> -			if ! valid_custom_tool "$1"; then
> -				return 1
> -			fi
> -			;;
> -	esac
> +    case "$1" in
> +	kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
> +	    ;; # happy
> +	*)
> +	    if ! valid_custom_tool "$1"; then
> +		return 1
> +	    fi
> +	    ;;
> +    esac
>  }
>  
>  init_merge_tool_path() {
> -	merge_tool_path=`git config mergetool.$1.path`
> -	if test -z "$merge_tool_path" ; then
> -		case "$1" in
> -			emerge)
> -				merge_tool_path=emacs
> -				;;
> -			*)
> -				merge_tool_path=$1
> -				;;
> -		esac
> -	fi
> +    merge_tool_path=`git config mergetool.$1.path`
> +    if test -z "$merge_tool_path" ; then
> +	case "$1" in
> +	    emerge)
> +		merge_tool_path=emacs
> +		;;
> +	    *)
> +		merge_tool_path=$1
> +		;;
> +	esac
> +    fi
>  }
>  
>  prompt_after_failed_merge() {
> @@ -389,9 +389,9 @@ prompt_after_failed_merge() {
>  if test -z "$merge_tool"; then
>      merge_tool=`git config merge.tool`
>      if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
> -	    echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
> -	    echo >&2 "Resetting to default..."
> -	    unset merge_tool
> +	echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
> +	echo >&2 "Resetting to default..."
> +	unset merge_tool
>      fi
>  fi
>  
> -- 
> 1.6.2.323.geaf6e
> 
> -- 
> Charles Bailey
> http://ccgi.hashpling.plus.com/blog/

-- 
		David

  reply	other threads:[~2009-03-31  6:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30  5:03 (unknown), David Aguilar
2009-03-30  5:03 ` [PATCH 1/8] mergetool: use tabs consistently David Aguilar
2009-03-30  5:03   ` [PATCH 2/8] mergetool: use $( ... ) instead of `backticks` David Aguilar
2009-03-30  5:03     ` [PATCH 3/8] sh-tools: add a git-sh-tools shell helper script David Aguilar
2009-03-30  5:03       ` [PATCH 4/8] mergetool: refactor git-mergetool to use git-sh-tools David Aguilar
2009-03-30  5:03         ` [PATCH 5/8] difftool: refactor git-difftool " David Aguilar
2009-03-30  5:03           ` [PATCH 6/8] sh-tools: add a run_merge_tool function David Aguilar
2009-03-30  5:03             ` [PATCH 7/8] mergetool: refactor git-mergetool to use run_merge_tool David Aguilar
2009-03-30  5:03               ` [PATCH 8/8] difftool: refactor git-difftool-helper " David Aguilar
2009-03-30  6:55             ` [PATCH 6/8] sh-tools: add a run_merge_tool function Markus Heidelberg
2009-03-30  7:32             ` Markus Heidelberg
2009-03-30  7:46               ` David Aguilar
2009-03-30  8:44   ` [PATCH 1/8] mergetool: use tabs consistently Junio C Hamano
2009-03-30  9:22     ` David Aguilar
2009-03-30 21:35     ` Charles Bailey
2009-03-31  6:36       ` David Aguilar [this message]
2009-04-01 17:56         ` Junio C Hamano
2009-03-30  7:02 ` Markus Heidelberg
2009-03-30  8:46   ` Re: Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090331063613.GA20690@gmail.com \
    --to=davvid@gmail.com \
    --cc=charles@hashpling.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).