Merge branch 'jc/ll-merge-expose-path'
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2015 19:21:45 +0000 (12:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2015 19:21:45 +0000 (12:21 -0700)
Traditionally, external low-level 3-way merge drivers are expected
to produce their results based solely on the contents of the three
variants given in temporary files named by %O, %A and %B on their
command line. Additionally allow them to look at the final path
(given by %P).

* jc/ll-merge-expose-path:
ll-merge: pass the original path to external drivers

1  2 
Documentation/gitattributes.txt
t/t6026-merge-attr.sh
index 70899b302365f1f441422778d7683d277924279f,3de7195bc2609c617935f86874d24ed421451add..81fe586948582fae4945029a5cd49e61b09fac5b
@@@ -80,7 -80,7 +80,7 @@@ Attributes which should be version-cont
  repositories (i.e., attributes of interest to all users) should go into
  `.gitattributes` files. Attributes that should affect all repositories
  for a single user should be placed in a file specified by the
 -`core.attributesfile` configuration option (see linkgit:git-config[1]).
 +`core.attributesFile` configuration option (see linkgit:git-config[1]).
  Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME
  is either not set or empty, $HOME/.config/git/attributes is used instead.
  Attributes for all users on a system should be placed in the
@@@ -774,7 -774,7 +774,7 @@@ To define a custom merge driver `filfre
  ----------------------------------------------------------------
  [merge "filfre"]
        name = feel-free merge driver
-       driver = filfre %O %A %B
+       driver = filfre %O %A %B %L %P
        recursive = binary
  ----------------------------------------------------------------
  
@@@ -800,6 -800,9 +800,9 @@@ merge between common ancestors, when th
  When left unspecified, the driver itself is used for both
  internal merge and the final merge.
  
+ The merge driver can learn the pathname in which the merged result
+ will be stored via placeholder `%P`.
  
  `conflict-marker-size`
  ^^^^^^^^^^^^^^^^^^^^^^
diff --combined t/t6026-merge-attr.sh
index 3c21938a6891feb61f821bc46ff8f09f1ee009d1,e38ebe8bbc5ed1f5291b0d8e8dbbc13db9aeeaca..04c0509c476de87bfb679f1c50556ca4c3a3d615
@@@ -11,7 -11,7 +11,7 @@@ test_expect_success setup 
  
        for f in text binary union
        do
 -              echo Initial >$f && git add $f || break
 +              echo Initial >$f && git add $f || return 1
        done &&
        test_tick &&
        git commit -m Initial &&
@@@ -19,7 -19,7 +19,7 @@@
        git branch side &&
        for f in text binary union
        do
 -              echo Master >>$f && git add $f || break
 +              echo Master >>$f && git add $f || return 1
        done &&
        test_tick &&
        git commit -m Master &&
@@@ -27,7 -27,7 +27,7 @@@
        git checkout side &&
        for f in text binary union
        do
 -              echo Side >>$f && git add $f || break
 +              echo Side >>$f && git add $f || return 1
        done &&
        test_tick &&
        git commit -m Side &&
@@@ -85,11 -85,12 +85,12 @@@ test_expect_success 'retry the merge wi
  cat >./custom-merge <<\EOF
  #!/bin/sh
  
- orig="$1" ours="$2" theirs="$3" exit="$4"
+ orig="$1" ours="$2" theirs="$3" exit="$4" path=$5
  (
        echo "orig is $orig"
        echo "ours is $ours"
        echo "theirs is $theirs"
+       echo "path is $path"
        echo "=== orig ==="
        cat "$orig"
        echo "=== ours ==="
@@@ -110,7 -111,7 +111,7 @@@ test_expect_success 'custom merge backe
  
        git reset --hard anchor &&
        git config --replace-all \
-       merge.custom.driver "./custom-merge %O %A %B 0" &&
+       merge.custom.driver "./custom-merge %O %A %B 0 %P" &&
        git config --replace-all \
        merge.custom.name "custom merge driver for testing" &&
  
        o=$(git unpack-file master^:text) &&
        a=$(git unpack-file side^:text) &&
        b=$(git unpack-file master:text) &&
-       sh -c "./custom-merge $o $a $b 0" &&
+       sh -c "./custom-merge $o $a $b 0 'text'" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
        rm -f $o $a $b
@@@ -131,7 -132,7 +132,7 @@@ test_expect_success 'custom merge backe
  
        git reset --hard anchor &&
        git config --replace-all \
-       merge.custom.driver "./custom-merge %O %A %B 1" &&
+       merge.custom.driver "./custom-merge %O %A %B 1 %P" &&
        git config --replace-all \
        merge.custom.name "custom merge driver for testing" &&
  
        o=$(git unpack-file master^:text) &&
        a=$(git unpack-file anchor:text) &&
        b=$(git unpack-file master:text) &&
-       sh -c "./custom-merge $o $a $b 0" &&
+       sh -c "./custom-merge $o $a $b 0 'text'" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
+       sed -e 1,3d -e 4q $a >check-3 &&
+       echo "path is text" >expect &&
+       cmp expect check-3 &&
        rm -f $o $a $b
  '