git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Mergetool generating blank files (1.5.3)

From
KWKelvie Wong <kelvie@ieee.org>
Date
Sep 27, 2007, 22:23 UTC
Message-ID
<94ccbe710709271523s7e4c7a1dh53e34bd460c31d1f@mail.gmail.com>
In-Reply-To
<7vir5vss58.fsf@gitster.siamese.dyndns.org>
On 9/27/07, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> When mergetool is run from a subdirectory, "ls-files -u" nicely
> limits the output to conflicted files in that directory, but
> we need to give the full path to cat-file plumbing to grab the
> contents of stages.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
>  * I earlier sent one with cd_to_toplevel but I think the
>    approach in this patch is nicer.
>
>  git-mergetool.sh |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index a0e44f7..3b1ec13 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -12,6 +12,7 @@ USAGE='[--tool=tool] [file to merge] ...'
>  SUBDIRECTORY_OK=Yes
>  . git-sh-setup
>  require_work_tree
> +prefix=$(git rev-parse --show-prefix)
>
>  # Returns true if the mode reflects a symlink
>  is_symlink () {
> @@ -162,9 +163,9 @@ merge_file () {
>      local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
>      remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
>
> -    base_present   && git cat-file blob ":1:$path" > "$BASE" 2>/dev/null
> -    local_present  && git cat-file blob ":2:$path" > "$LOCAL" 2>/dev/null
> -    remote_present && git cat-file blob ":3:$path" > "$REMOTE" 2>/dev/null
> +    base_present   && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null
> +    local_present  && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null
> +    remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null
>
>      if test -z "$local_mode" -o -z "$remote_mode"; then
>         echo "Deleted merge conflict for '$path':"
>
--- a/git-mergetool       2007-09-24 09:08:23.000000000 -0700
+++ b/git-mergetool        2007-09-27 15:04:15.000000000 -0700
@@ -12,6 +12,7 @@
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
+prefix=$(git rev-parse --show-prefix)

 # Returns true if the mode reflects a symlink
 is_symlink () {
@@ -162,9 +163,9 @@
     local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
     remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`

-    base_present   && git cat-file blob ":1:$path" > "$BASE" 2>/dev/null
-    local_present  && git cat-file blob ":2:$path" > "$LOCAL" 2>/dev/null
-    remote_present && git cat-file blob ":3:$path" > "$REMOTE" 2>/dev/null
+    base_present   && git cat-file blob ":1:$prefix$path" > "$BASE" 2>/dev/null
+    local_present  && git cat-file blob ":2:$prefix$path" > "$LOCAL"
2>/dev/null
+    remote_present && git cat-file blob ":3:$prefix$path" > "$REMOTE"
2>/dev/null

     if test -z "$local_mode" -o -z "$remote_mode"; then
        echo "Deleted merge conflict for '$path':"
@@ -251,7 +252,7 @@
            ;;
        emerge)
            if base_present ; then
-               emacs -f emerge-files-with-ancestor-command "$LOCAL"
"$REMOTE" "$BASE" "$path"
+               emacs -f emerge-files-with-ancestor-command "$LOCAL"
"$REMOTE" "$BASE" "$(basename "$path")"
            else
                emacs -f emerge-files-command "$LOCAL" "$REMOTE"
"$(basename "$path")"
            fi



Finally got it to work.  emacs (at least the version I'm using,
22.1.1) seems to set the $PWD via its first argument, that is,
$LOCAL's directory, and when it goes to save, it tries to save $path
on top of that.

The updated patch above would be just to use the basename, that is, if
it is certain that $LOCAL and $path will always reside in the same
directory -- and I believe, but am not certain, that this is the case.

Also, I am not sure if this is specific to my version of Emacs, so
perhaps some further testing is required.
-- 
Kelvie
Previous: Junio C HamanoNext: Theodore Tso
Message 23 of 28 in “Mergetool generating blank files (1.5.3)”
  1. Kelvie WongSep 27, 2007
  2. Pierre HabouzitSep 27, 2007
  3. Russ BrownSep 27, 2007
  4. Pierre HabouzitSep 27, 2007
  5. Theodore TsoSep 27, 2007
  6. Pierre HabouzitSep 27, 2007
  7. Peter BaumannSep 28, 2007
  8. Pierre HabouzitSep 28, 2007
  9. Jeff KingSep 27, 2007
  10. Pierre HabouzitSep 27, 2007
  11. Jeff KingSep 27, 2007
  12. Kelvie WongSep 27, 2007
  13. Junio C HamanoSep 27, 2007
  14. Kelvie WongSep 27, 2007
  15. Junio C HamanoSep 27, 2007
  16. Kelvie WongSep 27, 2007
  17. Junio C HamanoSep 27, 2007
  18. Junio C HamanoSep 27, 2007
  19. Kelvie WongSep 27, 2007
  20. Kelvie WongSep 27, 2007
  21. Junio C HamanoSep 27, 2007
  22. Junio C HamanoSep 27, 2007
  23. Kelvie WongSep 27, 2007
  24. Theodore TsoSep 27, 2007
  25. Kelvie WongSep 28, 2007
  26. David KastrupSep 28, 2007
  27. Theodore TsoSep 27, 2007
  28. David KågedalSep 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.