All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Junio C Hamano <gitster@pobox.com>, Richard Hansen <hansenr@google.com>
Cc: git@vger.kernel.org, davvid@gmail.com, sbeller@google.com,
	simon@ruderich.org
Subject: Re: [PATCH v3 13/13] mergetool: fix running in subdir when rerere enabled
Date: Mon, 9 Jan 2017 20:53:15 +0100	[thread overview]
Message-ID: <babb5073-97d1-3d03-02a5-9c690e86b8a0@kdbg.org> (raw)
In-Reply-To: <xmqqvatot5ob.fsf@gitster.mtv.corp.google.com>

Am 09.01.2017 um 20:05 schrieb Junio C Hamano:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> I wonder if it makes more sense to always move to toplevel upfront
>> and consistently use path from the toplevel, perhaps like the patch
>
> s/the patch/the attached patch/ I meant.
>
>> does.  The first hunk is what you wrote but only inside MERGE_RR
>> block, and the second hunk deals with converting end-user supplied
>> paths that are relative to the original relative to the top-level.
>>
>> The tweaking of $orderfile you have in the first hunk may have to be
>> tightened mimicking the way how "eval ... --sq ... ; shift" is used
>> in the second hunk to avoid confusion in case orderfile specified by
>> the end user happens to be the same as a valid revname
>> (e.g. "master").
>
> And here is a squash-able patch to illustrate what I mean.
>
> I removed both of the comment blocks as the code always works with
> the worktree-relative pathname after this patch while adjusting
> end-user supplied paths from relative to original cwd.  As that is
> how the core parts of the system (including the parts written in C)
> work, even though an explanation you did in the log message is
> needed to explain why the change was needed and what the change
> intended to do to readers of "git log", it is not necessary to
> explain it to the readers of the latest code, which is what the
> in-code comment is about.
>
> The single-liner addition to the test creates a branch whose name is
> the same as the specified orderfile to deliberately create a
> confusing situation.  I haven't tried, but I am fairly sure that the
> test will demonstrate how broken the orderfile=$(...) in the
> original is, if you apply the test part of the attached patch,
> without the changes to git-mergetool.sh, to your version.
>
>
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index 22f56c25a2..21f82d5b58 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -454,53 +454,34 @@ main () {
>  	merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
>  	merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
>
> -	if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR"
> +	prefix=$(git rev-parse --show-prefix) || exit 1
> +	cd_to_toplevel
> +
> +	if test -n "$orderfile"
>  	then
> -		# The pathnames output by the 'git rerere remaining'
> -		# command below are relative to the top-level
> -		# directory but the 'git diff --name-only' command
> -		# further below expects the pathnames to be relative
> -		# to the current working directory.  Thus, we cd to
> -		# the top-level directory before running 'git diff
> -		# --name-only'.  We change directories even earlier
> -		# (before running 'git rerere remaining') in case 'git
> -		# rerere remaining' is ever changed to output
> -		# pathnames relative to the current working directory.
> -		#
> -		# Changing directories breaks a relative $orderfile
> -		# pathname argument, so fix it up to be relative to
> -		# the top-level directory.
> -
> -		prefix=$(git rev-parse --show-prefix) || exit 1
> -		cd_to_toplevel
> -		if test -n "$orderfile"
> -		then
> -			orderfile=$(git rev-parse --prefix "$prefix" "$orderfile") || exit 1
> -		fi
> +		orderfile=$(
> +			git rev-parse --prefix "$prefix" -- "$orderfile" |
> +			sed -e 1d
> +		)
> +	fi
>
> +	if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR"
> +	then
>  		set -- $(git rerere remaining)
>  		if test $# -eq 0
>  		then
>  			print_noop_and_exit
>  		fi
> +	elif test $# -ge 0
> +	then
> +		eval "set -- $(git rev-parse --sq --prefix "$prefix" -- "$@")"
> +		shift
>  	fi
>
> -	# Note:  The pathnames output by 'git diff --name-only' are
> -	# relative to the top-level directory, but it expects input
> -	# pathnames to be relative to the current working directory.
> -	# Thus:
> -	#   * Either cd_to_toplevel must not be run before this or all
> -	#     relative input pathnames must be converted to be
> -	#     relative to the top-level directory (or absolute).
> -	#   * Either cd_to_toplevel must be run after this or all
> -	#     relative output pathnames must be converted to be
> -	#     relative to the current working directory (or absolute).
>  	files=$(git -c core.quotePath=false \
>  		diff --name-only --diff-filter=U \
>  		${orderfile:+"-O$orderfile"} -- "$@")
>
> -	cd_to_toplevel
> -
>  	if test -z "$files"
>  	then
>  		print_noop_and_exit

The control flow after this patch looks much more like what I had in 
mind. Thanks.

-- Hannes


  reply	other threads:[~2017-01-09 19:53 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04  0:50 [PATCH 0/4] fix mergetool+rerere+subdir regression Richard Hansen
2017-01-04  0:50 ` [PATCH 1/4] t7610: update branch names to match test number Richard Hansen
2017-01-04  0:50 ` [PATCH 2/4] t7610: make tests more independent and debuggable Richard Hansen
2017-01-04 20:27   ` Stefan Beller
2017-01-05 15:41     ` Richard Hansen
2017-01-05 15:46     ` Richard Hansen
2017-01-05 12:20   ` Simon Ruderich
2017-01-05 15:48     ` Richard Hansen
2017-01-04  0:50 ` [PATCH 3/4] t7610: add test case for rerere+mergetool+subdir bug Richard Hansen
2017-01-04  0:50 ` [PATCH 4/4] mergetool: fix running in subdir when rerere enabled Richard Hansen
2017-01-06  1:09 ` [PATCH v2 0/4] fix mergetool+rerere+subdir regression Richard Hansen
2017-01-06  1:09   ` [PATCH v2 1/4] t7610: update branch names to match test number Richard Hansen
2017-01-06  1:09   ` [PATCH v2 2/4] t7610: make tests more independent and debuggable Richard Hansen
2017-01-06  1:31     ` Stefan Beller
2017-01-07  1:53       ` Richard Hansen
2017-01-06  1:09   ` [PATCH v2 3/4] t7610: add test case for rerere+mergetool+subdir bug Richard Hansen
2017-01-06  1:09   ` [PATCH v2 4/4] mergetool: fix running in subdir when rerere enabled Richard Hansen
2017-01-06  9:42     ` Johannes Sixt
2017-01-07  2:16       ` Richard Hansen
2017-01-09  5:42   ` [PATCH v3 00/13] fix mergetool+rerere+subdir regression Richard Hansen
2017-01-09  5:42     ` [PATCH v3 01/13] .mailmap: Use my personal email address as my canonical Richard Hansen
2017-01-09  5:42     ` [PATCH v3 02/13] t7610: update branch names to match test number Richard Hansen
2017-01-09  5:42     ` [PATCH v3 03/13] t7610: Move setup code to the 'setup' test case Richard Hansen
2017-01-09  5:42     ` [PATCH v3 04/13] t7610: use test_when_finished for cleanup tasks Richard Hansen
2017-01-09  5:42     ` [PATCH v3 05/13] t7610: don't rely on state from previous test Richard Hansen
2017-01-09  5:42     ` [PATCH v3 06/13] t7610: run 'git reset --hard' after each test to clean up Richard Hansen
2017-01-09  5:42     ` [PATCH v3 07/13] t7610: delete some now-unnecessary 'git reset --hard' lines Richard Hansen
2017-01-09  5:42     ` [PATCH v3 08/13] t7610: always work on a test-specific branch Richard Hansen
2017-01-09  5:42     ` [PATCH v3 09/13] t7610: don't assume the checked-out commit Richard Hansen
2017-01-09  5:42     ` [PATCH v3 10/13] t7610: spell 'git reset --hard' consistently Richard Hansen
2017-01-09  5:42     ` [PATCH v3 11/13] t7610: add test case for rerere+mergetool+subdir bug Richard Hansen
2017-01-09  5:42     ` [PATCH v3 12/13] mergetool: take the "-O" out of $orderfile Richard Hansen
2017-01-09  5:42     ` [PATCH v3 13/13] mergetool: fix running in subdir when rerere enabled Richard Hansen
2017-01-09 18:12       ` Junio C Hamano
2017-01-09 19:05         ` Junio C Hamano
2017-01-09 19:53           ` Johannes Sixt [this message]
2017-01-09 22:57           ` Richard Hansen
2017-01-09 23:29           ` Junio C Hamano
2017-01-09 23:32             ` Junio C Hamano
2017-01-09 23:50             ` Richard Hansen
2017-01-09 18:49     ` [PATCH v3 00/13] fix mergetool+rerere+subdir regression Stefan Beller
2017-01-09 23:29     ` [PATCH v4 00/14] " Richard Hansen
2017-01-09 23:29       ` [PATCH v4 01/14] .mailmap: Use my personal email address as my canonical Richard Hansen
2017-01-09 23:29       ` [PATCH v4 02/14] rev-parse doc: use "--" in the --prefix example Richard Hansen
2017-01-09 23:29       ` [PATCH v4 03/14] t7610: update branch names to match test number Richard Hansen
2017-01-09 23:29       ` [PATCH v4 04/14] t7610: Move setup code to the 'setup' test case Richard Hansen
2017-01-09 23:29       ` [PATCH v4 05/14] t7610: use test_when_finished for cleanup tasks Richard Hansen
2017-01-09 23:29       ` [PATCH v4 06/14] t7610: don't rely on state from previous test Richard Hansen
2017-01-09 23:29       ` [PATCH v4 07/14] t7610: run 'git reset --hard' after each test to clean up Richard Hansen
2017-01-09 23:29       ` [PATCH v4 08/14] t7610: delete some now-unnecessary 'git reset --hard' lines Richard Hansen
2017-01-09 23:29       ` [PATCH v4 09/14] t7610: always work on a test-specific branch Richard Hansen
2017-01-09 23:29       ` [PATCH v4 10/14] t7610: don't assume the checked-out commit Richard Hansen
2017-01-09 23:29       ` [PATCH v4 11/14] t7610: spell 'git reset --hard' consistently Richard Hansen
2017-01-09 23:29       ` [PATCH v4 12/14] t7610: add test case for rerere+mergetool+subdir bug Richard Hansen
2017-01-09 23:29       ` [PATCH v4 13/14] mergetool: take the "-O" out of $orderfile Richard Hansen
2017-01-09 23:29       ` [PATCH v4 14/14] mergetool: fix running in subdir when rerere enabled Richard Hansen
2017-01-10  6:17         ` Johannes Sixt
2017-01-10 17:09           ` Richard Hansen
2017-01-10 19:25           ` Junio C Hamano
2017-01-10 20:29             ` Johannes Sixt
2017-01-10 20:41       ` [PATCH v5 00/14] fix mergetool+rerere+subdir regression Richard Hansen
2017-01-10 20:41         ` [PATCH v5 01/14] .mailmap: Use my personal email address as my canonical Richard Hansen
2017-01-10 20:41         ` [PATCH v5 02/14] rev-parse doc: pass "--" to rev-parse in the --prefix example Richard Hansen
2017-01-10 20:41         ` [PATCH v5 03/14] t7610: update branch names to match test number Richard Hansen
2017-01-10 20:41         ` [PATCH v5 04/14] t7610: Move setup code to the 'setup' test case Richard Hansen
2017-01-10 20:41         ` [PATCH v5 05/14] t7610: use test_when_finished for cleanup tasks Richard Hansen
2017-01-10 20:41         ` [PATCH v5 06/14] t7610: don't rely on state from previous test Richard Hansen
2017-01-10 20:41         ` [PATCH v5 07/14] t7610: run 'git reset --hard' after each test to clean up Richard Hansen
2017-01-10 20:41         ` [PATCH v5 08/14] t7610: delete some now-unnecessary 'git reset --hard' lines Richard Hansen
2017-01-10 20:41         ` [PATCH v5 09/14] t7610: always work on a test-specific branch Richard Hansen
2017-01-10 20:41         ` [PATCH v5 10/14] t7610: don't assume the checked-out commit Richard Hansen
2017-01-10 20:41         ` [PATCH v5 11/14] t7610: spell 'git reset --hard' consistently Richard Hansen
2017-01-10 20:42         ` [PATCH v5 12/14] t7610: add test case for rerere+mergetool+subdir bug Richard Hansen
2017-01-10 20:42         ` [PATCH v5 13/14] mergetool: take the "-O" out of $orderfile Richard Hansen
2017-01-10 20:42         ` [PATCH v5 14/14] mergetool: fix running in subdir when rerere enabled Richard Hansen
2017-01-10  4:36 ` [PATCH 0/4] fix mergetool+rerere+subdir regression David Aguilar

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

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

  git send-email \
    --in-reply-to=babb5073-97d1-3d03-02a5-9c690e86b8a0@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hansenr@google.com \
    --cc=sbeller@google.com \
    --cc=simon@ruderich.org \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.