git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git mergetool from next not working in subdirectory
@ 2009-01-30 13:05 Jonas Flodén
  2009-01-30 13:50 ` Johannes Gilger
  2009-01-30 14:06 ` Charles Bailey
  0 siblings, 2 replies; 8+ messages in thread
From: Jonas Flodén @ 2009-01-30 13:05 UTC (permalink / raw)
  To: git

Hi,

I just upgraded to the current 'next' version of git
(v1.6.1.2-418-gd79e69c). When I run git mergetool from
a subdirectory in my workspace I get the following output:
(with obfuscated output..)

~/src/rep/subdir $ git mergetool
Merging the files: a/b/file.c

git checkout-index: subdir/subdir/a/b/file.c is not in the cache
git checkout-index: subdir/subdir/a/b/file.c is not in the cache
git checkout-index: subdir/subdir/a/b/file.c is not in the cache
Normal merge conflict for 'a/b/file.c':
  {local}: modified

  {remote}: modified

Hit return to start merge resolution tool (kdiff3):

When I hit enter the merge resolution finishes right away
and the file ends up empty.

Note how subdir is duplicated in the output above.

This works perfectly fine with the 'master' version (1.6.1.2-253-ga34a).

Regards,
Jonas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git mergetool from next not working in subdirectory
  2009-01-30 13:05 git mergetool from next not working in subdirectory Jonas Flodén
@ 2009-01-30 13:50 ` Johannes Gilger
  2009-01-30 14:06 ` Charles Bailey
  1 sibling, 0 replies; 8+ messages in thread
From: Johannes Gilger @ 2009-01-30 13:50 UTC (permalink / raw)
  To: git

On 2009-01-30, Jonas Flodén <jonas.floden@gmail.com> wrote:
> I just upgraded to the current 'next' version of git
> ...
> This works perfectly fine with the 'master' version (1.6.1.2-253-ga34a).

Hi,

as you're running next you seem to be interested in the git development. 
That's why I suggest you try to bisect the commit that causes this. 
Fixing it is another problem entirely, but this way you'd at least take 
the tedious of work of a. duplicating your setup b. finding the bug off 
of the git developers.

Greetings,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git mergetool from next not working in subdirectory
  2009-01-30 13:05 git mergetool from next not working in subdirectory Jonas Flodén
  2009-01-30 13:50 ` Johannes Gilger
@ 2009-01-30 14:06 ` Charles Bailey
  2009-01-30 14:22   ` [PATCH] Quick and dirty mergetool fix Charles Bailey
  1 sibling, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2009-01-30 14:06 UTC (permalink / raw)
  To: Jonas Flodén; +Cc: git

On Fri, Jan 30, 2009 at 02:05:45PM +0100, Jonas Flodén wrote:
> ~/src/rep/subdir $ git mergetool
> Merging the files: a/b/file.c
> 
> git checkout-index: subdir/subdir/a/b/file.c is not in the cache
> git checkout-index: subdir/subdir/a/b/file.c is not in the cache
> git checkout-index: subdir/subdir/a/b/file.c is not in the cache
> Normal merge conflict for 'a/b/file.c':
>   {local}: modified
> 
>   {remote}: modified


Oh bother. I know exactly what this is. ls-files -u shows paths
relative to the work tree root, whereas checkout-index responds to
relative paths. Essentially the "$prefix" needs to come out of the
calls to the new checkout_staged_file shell function.

This is the bad commit 0ec7b6c26dad51f690cd985d4a5357634123c4b7

I can patch this (and more importantly add a test for this) tonight if
nobody beats me to it.

-- 
Charles Bailey
http://ccgi.hashpling.plus.com/blog/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Quick and dirty mergetool fix
  2009-01-30 14:06 ` Charles Bailey
@ 2009-01-30 14:22   ` Charles Bailey
  2009-01-30 16:00     ` Jonas Flodén
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2009-01-30 14:22 UTC (permalink / raw)
  To: Jonas Flodén; +Cc: git, Charles Bailey

---
 git-mergetool.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index aefdca7..db9ef43 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -161,9 +161,9 @@ merge_file () {
     local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
     remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
 
-    base_present   && checkout_staged_file 1 "$prefix$MERGED" "$BASE"
-    local_present  && checkout_staged_file 2 "$prefix$MERGED" "$LOCAL"
-    remote_present && checkout_staged_file 3 "$prefix$MERGED" "$REMOTE"
+    base_present   && checkout_staged_file 1 "$MERGED" "$BASE"
+    local_present  && checkout_staged_file 2 "$MERGED" "$LOCAL"
+    remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
 
     if test -z "$local_mode" -o -z "$remote_mode"; then
 	echo "Deleted merge conflict for '$MERGED':"
-- 
1.6.1.235.gc9d403

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Quick and dirty mergetool fix
  2009-01-30 14:22   ` [PATCH] Quick and dirty mergetool fix Charles Bailey
@ 2009-01-30 16:00     ` Jonas Flodén
  2009-01-30 16:16       ` [PATCH] Quick and dirty mergetool fix - take 2 Charles Bailey
  0 siblings, 1 reply; 8+ messages in thread
From: Jonas Flodén @ 2009-01-30 16:00 UTC (permalink / raw)
  To: Charles Bailey; +Cc: git

Hmm, with that patch I get get this instead:

mv: cannot stat `.merge_file_Yg2IIs': No such file or directory
mv: cannot stat `.merge_file_4xGT8t': No such file or directory
mv: cannot stat `.merge_file_4XAVAt': No such file or directory

Which seems to be a problem in checkout_staged_file()

The .merge_file_* files exists in the repository root (the dir with
.git) but I don't know how to fix that..

Thanks!

// Jonas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Quick and dirty mergetool fix - take 2
  2009-01-30 16:00     ` Jonas Flodén
@ 2009-01-30 16:16       ` Charles Bailey
  2009-01-30 16:18         ` Charles Bailey
  2009-01-30 16:22         ` Jonas Flodén
  0 siblings, 2 replies; 8+ messages in thread
From: Charles Bailey @ 2009-01-30 16:16 UTC (permalink / raw)
  To: Jonas Flodén; +Cc: git, Charles Bailey

---
 git-mergetool.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index aefdca7..d495a6b 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -131,7 +131,7 @@ checkout_staged_file () {
     tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^	]*\)	')
 
     if test $? -eq 0 -a -n "$tmpfile" ; then
-	mv -- "$tmpfile" "$3"
+	mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
     fi
 }
 
@@ -161,9 +161,9 @@ merge_file () {
     local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
     remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
 
-    base_present   && checkout_staged_file 1 "$prefix$MERGED" "$BASE"
-    local_present  && checkout_staged_file 2 "$prefix$MERGED" "$LOCAL"
-    remote_present && checkout_staged_file 3 "$prefix$MERGED" "$REMOTE"
+    base_present   && checkout_staged_file 1 "$MERGED" "$BASE"
+    local_present  && checkout_staged_file 2 "$MERGED" "$LOCAL"
+    remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
 
     if test -z "$local_mode" -o -z "$remote_mode"; then
 	echo "Deleted merge conflict for '$MERGED':"
-- 
1.6.1.235.gc9d403

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Quick and dirty mergetool fix - take 2
  2009-01-30 16:16       ` [PATCH] Quick and dirty mergetool fix - take 2 Charles Bailey
@ 2009-01-30 16:18         ` Charles Bailey
  2009-01-30 16:22         ` Jonas Flodén
  1 sibling, 0 replies; 8+ messages in thread
From: Charles Bailey @ 2009-01-30 16:18 UTC (permalink / raw)
  To: Jonas Flodén; +Cc: git

On Fri, Jan 30, 2009 at 04:16:06PM +0000, Charles Bailey wrote:

Sorry, I meant to add this comment to the last patch.

I have a test so I'm more confident about this version. It's not
signed off yet as I want to clean up the new test and make sure I've
considered everything - well more things - but it should at least work
now.

-- 
Charles Bailey
http://ccgi.hashpling.plus.com/blog/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Quick and dirty mergetool fix - take 2
  2009-01-30 16:16       ` [PATCH] Quick and dirty mergetool fix - take 2 Charles Bailey
  2009-01-30 16:18         ` Charles Bailey
@ 2009-01-30 16:22         ` Jonas Flodén
  1 sibling, 0 replies; 8+ messages in thread
From: Jonas Flodén @ 2009-01-30 16:22 UTC (permalink / raw)
  To: Charles Bailey; +Cc: git

Charles Bailey wrote:
> ---
>  git-mergetool.sh |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index aefdca7..d495a6b 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -131,7 +131,7 @@ checkout_staged_file () {
>      tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^	]*\)	')
>  
>      if test $? -eq 0 -a -n "$tmpfile" ; then
> -	mv -- "$tmpfile" "$3"
> +	mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
>      fi
>  }
>  
> @@ -161,9 +161,9 @@ merge_file () {
>      local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
>      remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
>  
> -    base_present   && checkout_staged_file 1 "$prefix$MERGED" "$BASE"
> -    local_present  && checkout_staged_file 2 "$prefix$MERGED" "$LOCAL"
> -    remote_present && checkout_staged_file 3 "$prefix$MERGED" "$REMOTE"
> +    base_present   && checkout_staged_file 1 "$MERGED" "$BASE"
> +    local_present  && checkout_staged_file 2 "$MERGED" "$LOCAL"
> +    remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
>  
>      if test -z "$local_mode" -o -z "$remote_mode"; then
>  	echo "Deleted merge conflict for '$MERGED':"

Yes, I was just about to propose a similar patch.

This solution works for me!

You might want to remove $prefix from the top of the
file since it's not used any more.

Thanks!

// Jonas

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-30 16:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-30 13:05 git mergetool from next not working in subdirectory Jonas Flodén
2009-01-30 13:50 ` Johannes Gilger
2009-01-30 14:06 ` Charles Bailey
2009-01-30 14:22   ` [PATCH] Quick and dirty mergetool fix Charles Bailey
2009-01-30 16:00     ` Jonas Flodén
2009-01-30 16:16       ` [PATCH] Quick and dirty mergetool fix - take 2 Charles Bailey
2009-01-30 16:18         ` Charles Bailey
2009-01-30 16:22         ` Jonas Flodén

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 NNTP newsgroup(s).