git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* What's cooking in git.git (Mar 2010, #05; Sat, 20)
@ 2010-03-20 21:00 Junio C Hamano
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2010-03-20 21:00 UTC (permalink / raw
  To: git

Here are the topics that have been cooking.  Commits prefixed with '-' are
only in 'pu' while commits prefixed with '+' are in 'next'.  The ones
marked with '.' do not appear in any of the integration branches, but I am
still holding onto them.

--------------------------------------------------
[Graduated to "master"]

* jk/maint-add-ignored-dir (2010-02-28) 3 commits
  (merged to 'next' on 2010-03-13 at df91e32)
 + tests for "git add ignored-dir/file" without -f
 + dir: fix COLLECT_IGNORED on excluded prefixes
 + t0050: mark non-working test as such

This replaced jc/maint-add-ignored-dir.  Will need to merge to maint
later.

* bg/apply-fix-blank-at-eof (2010-03-06) 5 commits
  (merged to 'next' on 2010-03-07 at daec679)
 + t3417: Add test cases for "rebase --whitespace=fix"
 + t4124: Add additional tests of --whitespace=fix
 + apply: Allow blank context lines to match beyond EOF
 + apply: Remove the quick rejection test
 + apply: Don't unnecessarily update line lengths in the preimage

* fl/askpass (2010-03-04) 2 commits
  (merged to 'next' on 2010-03-07 at 5ab370a)
 + git-core: Support retrieving passwords with GIT_ASKPASS
 + git-svn: Support retrieving passwords with GIT_ASKPASS

* jc/color-attrs (2010-02-27) 1 commit
  (merged to 'next' on 2010-03-08 at ba02883)
 + color: allow multiple attributes

* ml/color-grep (2010-03-07) 3 commits
  (merged to 'next' on 2010-03-08 at 24d1eb4)
 + grep: Colorize selected, context, and function lines
 + grep: Colorize filename, line number, and separator
 + Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*

* bw/union-merge-refactor (2010-03-01) 4 commits
  (merged to 'next' on 2010-03-10 at b917078)
 + merge-file: add option to select union merge favor
 + merge-file: add option to specify the marker size
  (merged to 'next' on 2010-03-07 at 9d1eff6)
 + refactor merge flags into xmparam_t
 + make union merge an xdl merge favor

* cc/reset-keep (2010-03-09) 6 commits
  (merged to 'next' on 2010-03-08 at 015ef4b)
 + Documentation: improve description of "git reset --keep"
  (merged to 'next' on 2010-03-07 at 5237d8e)
 + reset: disallow using --keep when there are unmerged entries
 + reset: disallow "reset --keep" outside a work tree
 + Documentation: reset: describe new "--keep" option
 + reset: add test cases for "--keep" option
 + reset: add option "--keep" to "git reset"

--------------------------------------------------
[New Topics]

* ar/config-from-command-line (2010-03-19) 1 commit
 - Allow passing of configuration parameters in the command line

* bc/t5505-fix (2010-03-19) 3 commits
 - t/t5505-remote.sh: escape * to prevent interpretation by shell as glob
 - t5505: add missing &&
 - t5505: remove unnecessary subshell invocations

Looked reasonable.  Soon in 'next'.

* bw/template-tool-buildconfig (2010-03-20) 2 commits
 - Modernize git calling conventions in hook templates
 - Make templates honour SHELL_PATH and PERL_PATH

Looked reasonable.  Soon in 'next'.

* mb/rebase-i-no-ff (2010-03-16) 1 commit
 - Teach --no-ff option to 'rebase -i'.

Looked reasonable.  Soon in 'next'.

* jn/merge-diff3-label (2010-03-17) 13 commits
 . cherry-pick, revert: add a label for ancestor
 . revert: clarify label on conflict hunks
 . compat: add mempcpy()
 . tests: document cherry-pick behavior in face of conflicts
 . checkout -m --conflict=diff3: add a label for ancestor
 . tests: document format of conflicts from checkout -m
 . merge_trees(): add ancestor label parameter for diff3-style output
 . merge_file(): add comment explaining behavior wrt conflict style
 . checkout --conflict=diff3: add a label for ancestor
 . ll_merge(): add ancestor label parameter for diff3-style output
 . merge-file --diff3: add a label for ancestor
 . xdl_merge(): move file1 and file2 labels to xmparam structure
 . xdl_merge(): add optional ancestor label to diff3-style output

This somewhat conflicts with bw/union-merge-refactor that in 'master'; I
could resolve the conflicts myself, but I'd rather not.  Jonathan, could
you rebase the series?

--------------------------------------------------
[Stalled]

* cw/test-lib-relicense (2010-02-22) 1 commit
 . test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

Ack-collection stopped at the last three names.  I am hoping Carl can take
it from there without my keeping an eye on it.

* js/rebase-origin-x (2010-02-05) 1 commit
 - [RFC w/o test and incomplete] rebase: add -x option to record original commit name

I retract my objection against the idea of -x; needs polishing before
moving forward.

* sg/bash-completion (2010-02-23) 4 commits
  (merged to 'next' on 2010-03-08 at bc59860)
 + bash: completion for gitk aliases
 + bash: support user-supplied completion scripts for aliases
 + bash: support user-supplied completion scripts for user's git commands
 + bash: improve aliased command recognition

Perhaps rename _git_frotz -> _git_complete_frotz?  I dunno.

* sd/log-decorate (2010-02-17) 3 commits
  (merged to 'next' on 2010-03-08 at 58a6fba)
 + log.decorate: usability fixes
 + Add `log.decorate' configuration variable.
 + git_config_maybe_bool()

Needs squelching the configuration setting when "--pretty=raw" is given,
at least, or possibly when any "--pretty" is explicitly given.

--------------------------------------------------
[Cooking]

* do/rebase-i-arbitrary (2010-03-14) 1 commit
 - rebase--interactive: don't require what's rebased to be a branch

Looked reasonable.  Soon in 'next'.

* ja/send-email-ehlo (2010-03-14) 3 commits
 - git-send-email.perl - try to give real name of the calling host to HELO/EHLO
 - git-send-email.perl: add option --smtp-debug
 - git-send-email.perl: improve error message in send_message()

Looked reasonable.  Soon in 'next'.

* ak/everyday-git (2009-10-21) 1 commit
 - everyday: fsck and gc are not everyday operations

Looked reasonable.  Soon in 'next'.

* bc/acl-test (2010-03-15) 5 commits
 - t/t1304: make a second colon optional in the mask ACL check
 - t/t1304: set the ACL effective rights mask
 - t/t1304: use 'test -r' to test readability rather than looking at mode bits
 - t/t1304: set the Default ACL base entries
 - t/t1304: avoid -d option to setfacl

Looked reasonable.  Soon in 'next'.

* bc/maint-daemon-sans-ss-family (2010-03-15) 1 commit
 - daemon.c: avoid accessing ss_family member of struct sockaddr_storage

Looked reasonable.  Soon in 'next'.

* ef/cherry-abbrev (2010-03-15) 1 commit
 - cherry: support --abbrev option

Looked reasonable.  Soon in 'next'.

* gh/maint-stash-show-error-message (2010-03-16) 1 commit
 - Improve error messages from 'git stash show'

Looked reasonable.  Soon in 'next'.

* jc/maint-refs-dangling (2010-03-15) 1 commit
  (merged to 'next' on 2010-03-16 at 376027b)
 + refs: ref entry with NULL sha1 is can be a dangling symref

Looked reasonable.  Soon in 'next'.

* rs/threaded-grep-context (2010-03-15) 1 commit
 - grep: enable threading for context line printing

Looked reasonable.  Soon in 'next'.

* pb/log-first-parent-p-m (2010-03-09) 5 commits
  (merged to 'next' on 2010-03-15 at 0ae494e)
 + show --first-parent/-m: do not default to --cc
 + show -c: show patch text
 + revision: introduce setup_revision_opt
 + t4013: add tests for log -p -m --first-parent
  (merged to 'next' on 2010-02-17 at 2f8e5ae)
 + git log -p -m: document -m and honor --first-parent

Ready for 'master'.

* jl/submodule-diff-dirtiness (2010-03-13) 5 commits
  (merged to 'next' on 2010-03-15 at 9601fd9)
 + git status: ignoring untracked files must apply to submodules too
  (merged to 'next' on 2010-03-13 at f9bfd8a)
 + git status: Fix false positive "new commits" output for dirty submodules
 + Refactor dirty submodule detection in diff-lib.c
  (merged to 'next' on 2010-03-08 at 33f7a57)
 + git status: Show detailed dirty status of submodules in long format
  (merged to 'next' on 2010-03-04 at 58b2645)
 + git diff --submodule: Show detailed dirty status of submodules

Ready for 'master'.

* cc/cherry-pick-ff (2010-03-06) 6 commits
  (merged to 'next' on 2010-03-20 at fdfcd14)
 + rebase -i: use new --ff cherry-pick option
  (merged to 'next' on 2010-03-07 at 5589b26)
 + Documentation: describe new cherry-pick --ff option
 + cherry-pick: add tests for new --ff option
 + revert: add --ff option to allow fast forward when cherry-picking
 + builtin/merge: make checkout_fast_forward() non static
 + parse-options: add parse_options_concat() to concat options

Ready for 'master'.

* js/async-thread (2010-03-09) 7 commits
 - Enable threaded async procedures whenever pthreads is available
  (merged to 'next' on 2010-03-20 at 9939243)
 + Dying in an async procedure should only exit the thread, not the process.
 + Reimplement async procedures using pthreads
 + Windows: more pthreads functions
 + Fix signature of fcntl() compatibility dummy
 + Make report() from usage.c public as vreportf() and use it.
 + Modernize t5530-upload-pack-error.

The tip one will be soon in 'next', but one step at a time.

* nd/setup (2010-03-08) 21 commits
 - index-pack: use RUN_SETUP_GENTLY
 - index-pack: trust the prefix returned by setup_git_directory_gently()
 - worktree setup: calculate prefix even if no worktree is found
 - merge-file: use RUN_SETUP_GENTLY
 - var: use RUN_SETUP_GENTLY
 - ls-remote: use RUN_SETUP_GENTLY
 - help: use RUN_SETUP_GENTLY
 - diff: use RUN_SETUP_GENTLY
 - bundle: use RUN_SETUP_GENTLY
 - apply: use RUN_SETUP_GENTLY
 - verify-pack: use RUN_SETUP_GENTLY
 - check-ref-format: use RUN_SETUP_GENTLY
 - mailinfo: use RUN_SETUP_GENTLY
 - archive: use RUN_SETUP_GENTLY
 - builtin: USE_PAGER should not be used without RUN_SETUP*
 - grep: use RUN_SETUP_GENTLY
 - shortlog: use RUN_SETUP_GENTLY
 - hash-object: use RUN_SETUP_GENTLY
 - config: use RUN_SETUP_GENTLY
 - builtin: Support RUN_SETUP_GENTLY to set up repository early if found
 - builtin: introduce startup_info struct

* sb/notes-parse-opt (2010-02-27) 1 commit
 - notes: rework subcommands and parse options
 (this branch uses tr/notes-display.)

* jh/maint-submodule-status-in-void (2010-03-09) 2 commits
  (merged to 'next' on 2010-03-15 at 49af9de)
 + git submodule summary: Handle HEAD as argument when on an unborn branch
  (merged to 'next' on 2010-03-08 at 0697bf4)
 + submodule summary: do not fail before the first commit

* tr/notes-display (2010-03-12) 13 commits
  (merged to 'next' on 2010-03-15 at 3329361)
 + git-notes(1): add a section about the meaning of history
 + notes: track whether notes_trees were changed at all
 + notes: add shorthand --ref to override GIT_NOTES_REF
 + commit --amend: copy notes to the new commit
 + rebase: support automatic notes copying
 + notes: implement helpers needed for note copying during rewrite
 + notes: implement 'git notes copy --stdin'
 + rebase -i: invoke post-rewrite hook
 + rebase: invoke post-rewrite hook
 + commit --amend: invoke post-rewrite hook
 + Documentation: document post-rewrite hook
 + Support showing notes from more than one notes tree
 + test-lib: unset GIT_NOTES_REF to stop it from influencing tests
 (this branch is used by sb/notes-parse-opt.)

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

* [PATCH 0/14] jn/merge-diff3-label
  2010-03-20 21:00 What's cooking in git.git (Mar 2010, #05; Sat, 20) Junio C Hamano
@ 2010-03-21  0:25 ` Jonathan Nieder
  2010-03-21  0:27   ` [PATCH 01/14] tests: document format of conflicts from checkout -m Jonathan Nieder
                     ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:25 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

Junio C Hamano wrote:

> * jn/merge-diff3-label (2010-03-17) 13 commits
>  . cherry-pick, revert: add a label for ancestor
>  . revert: clarify label on conflict hunks
>  . compat: add mempcpy()
>  . tests: document cherry-pick behavior in face of conflicts
>  . checkout -m --conflict=diff3: add a label for ancestor
>  . tests: document format of conflicts from checkout -m
>  . merge_trees(): add ancestor label parameter for diff3-style output
>  . merge_file(): add comment explaining behavior wrt conflict style
>  . checkout --conflict=diff3: add a label for ancestor
>  . ll_merge(): add ancestor label parameter for diff3-style output
>  . merge-file --diff3: add a label for ancestor
>  . xdl_merge(): move file1 and file2 labels to xmparam structure
>  . xdl_merge(): add optional ancestor label to diff3-style output
> 
> This somewhat conflicts with bw/union-merge-refactor that in 'master'; I
> could resolve the conflicts myself, but I'd rather not.  Jonathan, could
> you rebase the series?

Sure thing.  Here is the latest verison.

Jonathan Nieder (14):
  tests: document format of conflicts from checkout -m
  tests: document cherry-pick behavior in face of conflicts
  xdl_merge(): add optional ancestor label to diff3-style output
  xdl_merge(): move file1 and file2 labels to xmparam structure
  merge-file --diff3: add a label for ancestor
  ll_merge(): add ancestor label parameter for diff3-style output
  checkout --conflict=diff3: add a label for ancestor
  merge_file(): add comment explaining behavior wrt conflict style
  merge_trees(): add ancestor label parameter for diff3-style output
  checkout -m --conflict=diff3: add a label for ancestor
  compat: add mempcpy()
  revert: clarify label on conflict hunks
  cherry-pick, revert: add a label for ancestor
  merge-recursive: add a label for ancestor

 builtin/checkout.c              |    3 +-
 builtin/merge-file.c            |    6 +-
 builtin/revert.c                |  103 +++++++++++++--------
 git-compat-util.h               |    9 ++
 ll-merge.c                      |   24 +++--
 ll-merge.h                      |    2 +-
 merge-file.c                    |    8 ++-
 merge-recursive.c               |   12 ++-
 merge-recursive.h               |    1 +
 rerere.c                        |    4 +-
 t/t3507-cherry-pick-conflict.sh |  198 +++++++++++++++++++++++++++++++++++++++
 t/t6023-merge-file.sh           |    4 +-
 t/t7201-co.sh                   |   69 ++++++++++++-
 xdiff/xdiff.h                   |    6 +-
 xdiff/xmerge.c                  |   35 +++++--
 15 files changed, 405 insertions(+), 79 deletions(-)
 create mode 100644 t/t3507-cherry-pick-conflict.sh

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

* [PATCH 01/14] tests: document format of conflicts from checkout -m
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
@ 2010-03-21  0:27   ` Jonathan Nieder
  2010-03-21  0:28   ` [PATCH 02/14] tests: document cherry-pick behavior in face of conflicts Jonathan Nieder
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:27 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

We are about to change the format of the conflict hunks that ‘checkout
--merge’ writes.  Add tests checking the current behavior first.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Unchanged from
<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142383>.

 t/t7201-co.sh |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index d20ed61..01175f7 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -11,10 +11,12 @@ Test switching across them.
   ! [master] Initial A one, A two
    * [renamer] Renamer R one->uno, M two
     ! [side] Side M one, D two, A three
-  ---
-    + [side] Side M one, D two, A three
-   *  [renamer] Renamer R one->uno, M two
-  +*+ [master] Initial A one, A two
+     ! [simple] Simple D one, M two
+  ----
+     + [simple] Simple D one, M two
+    +  [side] Side M one, D two, A three
+   *   [renamer] Renamer R one->uno, M two
+  +*++ [master] Initial A one, A two
 
 '
 
@@ -52,6 +54,11 @@ test_expect_success setup '
 	git update-index --add --remove one two three &&
 	git commit -m "Side M one, D two, A three" &&
 
+	git checkout -b simple master &&
+	rm -f one &&
+	fill a c e > two &&
+	git commit -a -m "Simple D one, M two" &&
+
 	git checkout master
 '
 
@@ -166,6 +173,56 @@ test_expect_success 'checkout -m with merge conflict' '
 	! test -s current
 '
 
+test_expect_success 'format of merge conflict from checkout -m' '
+
+	git checkout -f master && git clean -f &&
+
+	fill b d > two &&
+	git checkout -m simple &&
+
+	git ls-files >current &&
+	fill same two two two >expect &&
+	test_cmp current expect &&
+
+	cat <<-EOF >expect &&
+	<<<<<<< simple
+	a
+	c
+	e
+	=======
+	b
+	d
+	>>>>>>> local
+	EOF
+	test_cmp two expect
+'
+
+test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
+
+	git checkout -f master && git reset --hard && git clean -f &&
+
+	fill b d > two &&
+	git checkout --merge --conflict=diff3 simple &&
+
+	cat <<-EOF >expect &&
+	<<<<<<< simple
+	a
+	c
+	e
+	|||||||
+	a
+	b
+	c
+	d
+	e
+	=======
+	b
+	d
+	>>>>>>> local
+	EOF
+	test_cmp two expect
+'
+
 test_expect_success 'checkout to detach HEAD (with advice declined)' '
 
 	git config advice.detachedHead false &&
-- 
1.7.0.2

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

* [PATCH 02/14] tests: document cherry-pick behavior in face of conflicts
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
  2010-03-21  0:27   ` [PATCH 01/14] tests: document format of conflicts from checkout -m Jonathan Nieder
@ 2010-03-21  0:28   ` Jonathan Nieder
  2010-03-21  0:31   ` [PATCH 03/14] xdl_merge(): add optional ancestor label to diff3-style output Jonathan Nieder
                     ` (11 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:28 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

We are about to change the format of the conflict hunks that
cherry-pick and revert write.  Add tests checking the current behavior
first.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142385

 t/t3507-cherry-pick-conflict.sh |  198 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 198 insertions(+), 0 deletions(-)
 create mode 100644 t/t3507-cherry-pick-conflict.sh

diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
new file mode 100644
index 0000000..e856356
--- /dev/null
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -0,0 +1,198 @@
+#!/bin/sh
+
+test_description='test cherry-pick and revert with conflicts
+
+  -
+  + picked: rewrites foo to c
+  + base: rewrites foo to b
+  + initial: writes foo as a, unrelated as unrelated
+
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+	echo unrelated >unrelated &&
+	git add unrelated &&
+	test_commit initial foo a &&
+	test_commit base foo b &&
+	test_commit picked foo c &&
+	git config advice.detachedhead false
+
+'
+
+test_expect_success 'failed cherry-pick does not advance HEAD' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	head=$(git rev-parse HEAD) &&
+	test_must_fail git cherry-pick picked &&
+	newhead=$(git rev-parse HEAD) &&
+
+	test "$head" = "$newhead"
+'
+
+test_expect_success 'failed cherry-pick produces dirty index' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+
+	test_must_fail git update-index --refresh -q &&
+	test_must_fail git diff-index --exit-code HEAD
+'
+
+test_expect_success 'failed cherry-pick registers participants in index' '
+
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+	{
+		git checkout base -- foo &&
+		git ls-files --stage foo &&
+		git checkout initial -- foo &&
+		git ls-files --stage foo &&
+		git checkout picked -- foo &&
+		git ls-files --stage foo
+	} > stages &&
+	sed "
+		1 s/ 0	/ 1	/
+		2 s/ 0	/ 2	/
+		3 s/ 0	/ 3	/
+	" < stages > expected &&
+	git checkout -f initial^0 &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+	git ls-files --stage --unmerged > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'failed cherry-pick describes conflict in work tree' '
+
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+	cat <<-EOF > expected &&
+	<<<<<<< HEAD
+	a
+	=======
+	c
+	>>>>>>> objid picked
+	EOF
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+
+	sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'diff3 -m style' '
+
+	git config merge.conflictstyle diff3 &&
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+	cat <<-EOF > expected &&
+	<<<<<<< HEAD
+	a
+	|||||||
+	b
+	=======
+	c
+	>>>>>>> objid picked
+	EOF
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git cherry-pick picked &&
+
+	sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'revert also handles conflicts sanely' '
+
+	git config --unset merge.conflictstyle &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+	cat <<-EOF > expected &&
+	<<<<<<< HEAD
+	a
+	=======
+	b
+	>>>>>>> objid picked
+	EOF
+	{
+		git checkout picked -- foo &&
+		git ls-files --stage foo &&
+		git checkout initial -- foo &&
+		git ls-files --stage foo &&
+		git checkout base -- foo &&
+		git ls-files --stage foo
+	} > stages &&
+	sed "
+		1 s/ 0	/ 1	/
+		2 s/ 0	/ 2	/
+		3 s/ 0	/ 3	/
+	" < stages > expected-stages &&
+	git checkout -f initial^0 &&
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	head=$(git rev-parse HEAD) &&
+	test_must_fail git revert picked &&
+	newhead=$(git rev-parse HEAD) &&
+	git ls-files --stage --unmerged > actual-stages &&
+
+	test "$head" = "$newhead" &&
+	test_must_fail git update-index --refresh -q &&
+	test_must_fail git diff-index --exit-code HEAD &&
+	test_cmp expected-stages actual-stages &&
+	sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'revert conflict, diff3 -m style' '
+	git config merge.conflictstyle diff3 &&
+	git checkout -f initial^0 &&
+	git read-tree -u --reset HEAD &&
+	git clean -d -f -f -q -x &&
+	cat <<-EOF > expected &&
+	<<<<<<< HEAD
+	a
+	|||||||
+	c
+	=======
+	b
+	>>>>>>> objid picked
+	EOF
+
+	git update-index --refresh &&
+	git diff-index --exit-code HEAD &&
+
+	test_must_fail git revert picked &&
+
+	sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
+	test_cmp expected actual
+'
+
+test_done
-- 
1.7.0.2

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

* [PATCH 03/14] xdl_merge(): add optional ancestor label to diff3-style output
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
  2010-03-21  0:27   ` [PATCH 01/14] tests: document format of conflicts from checkout -m Jonathan Nieder
  2010-03-21  0:28   ` [PATCH 02/14] tests: document cherry-pick behavior in face of conflicts Jonathan Nieder
@ 2010-03-21  0:31   ` Jonathan Nieder
  2010-03-21  0:35   ` [PATCH 04/14] xdl_merge(): move file1 and file2 labels to xmparam structure Jonathan Nieder
                     ` (10 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:31 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

The ‘git checkout --conflict=diff3’ command can be used to
present conflicts hunks including text from the common ancestor:

	<<<<<<< ours
	ourside
	|||||||
	original
	=======
	theirside
	>>>>>>> theirs

The added information is helpful for resolving merges by hand, and
merge tools can usually grok it because it is very similar to the
output from diff3 -m.

A subtle change can help more tools to understand the output.  ‘diff3’
includes the name of the merge base on the ||||||| line of the output,
and some tools misparse the conflict hunks without it.  Add a new
xmp->ancestor parameter to xdl_merge() for use with conflict style
XDL_MERGE_DIFF3 as a label on the ||||||| line for any conflict hunks.

If xmp->ancestor is NULL, the output format is unchanged.  Thus, this
change only provides unexposed plumbing for the new feature; it does
not affect the outward behavior of git.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Bert Wesarg <Bert.Wesarg@googlemail.com>
---
Small stylistic change:

	const char *const ancestor_name = xmp->ancestor;

as suggested in
<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142393>.

 xdiff/xdiff.h  |    1 +
 xdiff/xmerge.c |   16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index a71763a..6eb5fff 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -117,6 +117,7 @@ typedef struct s_xmparam {
 	int level;
 	int favor;
 	int style;
+	const char *ancestor;	/* label for orig */
 } xmparam_t;
 
 #define DEFAULT_CONFLICT_MARKER_SIZE 7
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 87cafa7..9fc80ad 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -145,11 +145,13 @@ static int xdl_orig_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest)
 
 static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
 			      xdfenv_t *xe2, const char *name2,
+			      const char *name3,
 			      int size, int i, int style,
 			      xdmerge_t *m, char *dest, int marker_size)
 {
 	int marker1_size = (name1 ? strlen(name1) + 1 : 0);
 	int marker2_size = (name2 ? strlen(name2) + 1 : 0);
+	int marker3_size = (name3 ? strlen(name3) + 1 : 0);
 	int j;
 
 	if (marker_size <= 0)
@@ -179,10 +181,15 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
 	if (style == XDL_MERGE_DIFF3) {
 		/* Shared preimage */
 		if (!dest) {
-			size += marker_size + 1;
+			size += marker_size + 1 + marker3_size;
 		} else {
 			for (j = 0; j < marker_size; j++)
 				dest[size++] = '|';
+			if (marker3_size) {
+				dest[size] = ' ';
+				memcpy(dest + size + 1, name3, marker3_size - 1);
+				size += marker3_size;
+			}
 			dest[size++] = '\n';
 		}
 		size += xdl_orig_copy(xe1, m->i0, m->chg0, 1,
@@ -217,6 +224,7 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
 
 static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
 				 xdfenv_t *xe2, const char *name2,
+				 const char *ancestor_name,
 				 int favor,
 				 xdmerge_t *m, char *dest, int style,
 				 int marker_size)
@@ -229,6 +237,7 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
 
 		if (m->mode == 0)
 			size = fill_conflict_hunk(xe1, name1, xe2, name2,
+						  ancestor_name,
 						  size, i, style, m, dest,
 						  marker_size);
 		else if (m->mode & 3) {
@@ -403,6 +412,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 		xmparam_t const *xmp, mmbuffer_t *result) {
 	xdmerge_t *changes, *c;
 	xpparam_t const *xpp = &xmp->xpp;
+	const char *const ancestor_name = xmp->ancestor;
 	int i0, i1, i2, chg0, chg1, chg2;
 	int level = xmp->level;
 	int style = xmp->style;
@@ -540,6 +550,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 	if (result) {
 		int marker_size = xmp->marker_size;
 		int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,
+						 ancestor_name,
 						 favor, changes, NULL, style,
 						 marker_size);
 		result->ptr = xdl_malloc(size);
@@ -548,7 +559,8 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 			return -1;
 		}
 		result->size = size;
-		xdl_fill_merge_buffer(xe1, name1, xe2, name2, favor, changes,
+		xdl_fill_merge_buffer(xe1, name1, xe2, name2,
+				      ancestor_name, favor, changes,
 				      result->ptr, style, marker_size);
 	}
 	return xdl_cleanup_merge(changes);
-- 
1.7.0.2

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

* [PATCH 04/14] xdl_merge(): move file1 and file2 labels to xmparam structure
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (2 preceding siblings ...)
  2010-03-21  0:31   ` [PATCH 03/14] xdl_merge(): add optional ancestor label to diff3-style output Jonathan Nieder
@ 2010-03-21  0:35   ` Jonathan Nieder
  2010-03-21  0:37   ` [PATCH 05/14] merge-file --diff3: add a label for ancestor Jonathan Nieder
                     ` (9 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:35 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

The labels for the three participants in a potential conflict are all
optional arguments for the xdiff merge routine; if they are NULL, then
xdl_merge() can cope by omitting the labels from its output.  Move
them to the xmparam structure to allow new callers to save some
keystrokes where they are not needed.

This also has the virtue of making the xdiff merge interface more
similar to merge_trees, which might make it easier to learn.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Applied saved resolution for conflict with commit 560119b (refactor merge
flags into xmparam_t, 2010-03-01).  Thanks for writing rerere!

Previous version is at
<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142377>.

 builtin/merge-file.c |    5 +++--
 ll-merge.c           |    4 +++-
 xdiff/xdiff.h        |    5 +++--
 xdiff/xmerge.c       |   19 +++++++++++--------
 4 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 69cc683..65eb790 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -77,8 +77,9 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 					argv[i]);
 	}
 
-	ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
-			&xmp, &result);
+	xmp.file1 = names[0];
+	xmp.file2 = names[2];
+	ret = xdl_merge(mmfs + 1, mmfs + 0, mmfs + 2, &xmp, &result);
 
 	for (i = 0; i < 3; i++)
 		free(mmfs[i].ptr);
diff --git a/ll-merge.c b/ll-merge.c
index 82c7742..184948d 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -83,7 +83,9 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 		xmp.style = git_xmerge_style;
 	if (marker_size > 0)
 		xmp.marker_size = marker_size;
-	return xdl_merge(orig, src1, name1, src2, name2, &xmp, result);
+	xmp.file1 = name1;
+	xmp.file2 = name2;
+	return xdl_merge(orig, src1, src2, &xmp, result);
 }
 
 static int ll_union_merge(const struct ll_merge_driver *drv_unused,
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 6eb5fff..711048e 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -118,12 +118,13 @@ typedef struct s_xmparam {
 	int favor;
 	int style;
 	const char *ancestor;	/* label for orig */
+	const char *file1;	/* label for mf1 */
+	const char *file2;	/* label for mf2 */
 } xmparam_t;
 
 #define DEFAULT_CONFLICT_MARKER_SIZE 7
 
-int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
-		mmfile_t *mf2, const char *name2,
+int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
 		xmparam_t const *xmp, mmbuffer_t *result);
 
 #ifdef __cplusplus
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 9fc80ad..16dd9ac 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -407,12 +407,15 @@ static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m,
  *
  * returns < 0 on error, == 0 for no conflicts, else number of conflicts
  */
-static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
-		xdfenv_t *xe2, xdchange_t *xscr2, const char *name2,
-		xmparam_t const *xmp, mmbuffer_t *result) {
+static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
+		xdfenv_t *xe2, xdchange_t *xscr2,
+		xmparam_t const *xmp, mmbuffer_t *result)
+{
 	xdmerge_t *changes, *c;
 	xpparam_t const *xpp = &xmp->xpp;
 	const char *const ancestor_name = xmp->ancestor;
+	const char *const name1 = xmp->file1;
+	const char *const name2 = xmp->file2;
 	int i0, i1, i2, chg0, chg1, chg2;
 	int level = xmp->level;
 	int style = xmp->style;
@@ -566,9 +569,9 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
 	return xdl_cleanup_merge(changes);
 }
 
-int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
-		mmfile_t *mf2, const char *name2,
-		xmparam_t const *xmp, mmbuffer_t *result) {
+int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
+		xmparam_t const *xmp, mmbuffer_t *result)
+{
 	xdchange_t *xscr1, *xscr2;
 	xdfenv_t xe1, xe2;
 	int status;
@@ -603,8 +606,8 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
 		memcpy(result->ptr, mf1->ptr, mf1->size);
 		result->size = mf1->size;
 	} else {
-		status = xdl_do_merge(&xe1, xscr1, name1,
-				      &xe2, xscr2, name2,
+		status = xdl_do_merge(&xe1, xscr1,
+				      &xe2, xscr2,
 				      xmp, result);
 	}
 	xdl_free_script(xscr1);
-- 
1.7.0.2

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

* [PATCH 05/14] merge-file --diff3: add a label for ancestor
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (3 preceding siblings ...)
  2010-03-21  0:35   ` [PATCH 04/14] xdl_merge(): move file1 and file2 labels to xmparam structure Jonathan Nieder
@ 2010-03-21  0:37   ` Jonathan Nieder
  2010-03-21  0:38   ` [PATCH 06/14] ll_merge(): add ancestor label parameter for diff3-style output Jonathan Nieder
                     ` (8 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:37 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

git merge-file --diff3 can be used to present conflicts hunks
including text from the common ancestor.

The added information is helpful for resolving a merge by hand, and
merge tools can usually grok it because it looks like output from
diff3 -m.  However, ‘diff3’ includes a label for the merge base on the
||||||| line and some tools cannot parse conflict hunks without such a
label.  Write the base-name as passed in a -L option (or the name of
the ancestor file by default) on that line.

git rerere will not have trouble parsing this output, since instead of
looking for a newline, it looks for whitespace after the |||||||
marker.  Since rerere includes its own code for recreating conflict
hunks, conflict identifiers are unaffected.  No other code in git tries
to parse conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Adapts test for 11f3aa23 (merge-file: add option to specify the marker
size, 2010-03-01) as described at
<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142378>.

 builtin/merge-file.c  |    1 +
 t/t6023-merge-file.sh |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 65eb790..610849a 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -77,6 +77,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 					argv[i]);
 	}
 
+	xmp.ancestor = names[1];
 	xmp.file1 = names[0];
 	xmp.file2 = names[2];
 	ret = xdl_merge(mmfs + 1, mmfs + 0, mmfs + 2, &xmp, &result);
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 5034dd1..d486d73 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -181,7 +181,7 @@ et nihil mihi deerit;
 
 In loco pascuae ibi me collocavit;
 super aquam refectionis educavit me.
-|||||||
+||||||| new5.txt
 et nihil mihi deerit.
 In loco pascuae ibi me collocavit,
 super aquam refectionis educavit me;
@@ -225,7 +225,7 @@ et nihil mihi deerit;
 
 In loco pascuae ibi me collocavit;
 super aquam refectionis educavit me.
-||||||||||
+|||||||||| new5.txt
 et nihil mihi deerit.
 In loco pascuae ibi me collocavit,
 super aquam refectionis educavit me;
-- 
1.7.0.2

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

* [PATCH 06/14] ll_merge(): add ancestor label parameter for diff3-style output
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (4 preceding siblings ...)
  2010-03-21  0:37   ` [PATCH 05/14] merge-file --diff3: add a label for ancestor Jonathan Nieder
@ 2010-03-21  0:38   ` Jonathan Nieder
  2010-03-21  0:40   ` [PATCH 07/14] checkout --conflict=diff3: add a label for ancestor Jonathan Nieder
                     ` (7 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:38 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

Commands using the ll_merge() function will present conflict hunks
imitating ‘diff3 -m’ output if the merge.conflictstyle configuration
option is set appropriately.  Unlike ‘diff3 -m’, the output does not
include a label for the merge base on the ||||||| line of the output,
and some tools misparse the conflict hunks without that.

Add a new ancestor_label parameter to ll_merge() to give callers the
power to rectify this situation.  If ancestor_label is NULL, the output
format is unchanged.  All callers pass NULL for now.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142379>.

 builtin/checkout.c |    2 +-
 ll-merge.c         |   20 +++++++++++---------
 ll-merge.h         |    2 +-
 merge-file.c       |    2 +-
 merge-recursive.c  |    2 +-
 rerere.c           |    4 ++--
 6 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index acefaaf..d67f809 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	read_mmblob(&ours, active_cache[pos+1]->sha1);
 	read_mmblob(&theirs, active_cache[pos+2]->sha1);
 
-	status = ll_merge(&result_buf, path, &ancestor,
+	status = ll_merge(&result_buf, path, &ancestor, NULL,
 			  &ours, "ours", &theirs, "theirs", 0);
 	free(ancestor.ptr);
 	free(ours.ptr);
diff --git a/ll-merge.c b/ll-merge.c
index 184948d..f9b3d85 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -15,7 +15,7 @@ struct ll_merge_driver;
 typedef int (*ll_merge_fn)(const struct ll_merge_driver *,
 			   mmbuffer_t *result,
 			   const char *path,
-			   mmfile_t *orig,
+			   mmfile_t *orig, const char *orig_name,
 			   mmfile_t *src1, const char *name1,
 			   mmfile_t *src2, const char *name2,
 			   int flag,
@@ -36,7 +36,7 @@ struct ll_merge_driver {
 static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
 			   mmbuffer_t *result,
 			   const char *path_unused,
-			   mmfile_t *orig,
+			   mmfile_t *orig, const char *orig_name,
 			   mmfile_t *src1, const char *name1,
 			   mmfile_t *src2, const char *name2,
 			   int flag, int marker_size)
@@ -57,7 +57,7 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
 static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 			mmbuffer_t *result,
 			const char *path,
-			mmfile_t *orig,
+			mmfile_t *orig, const char *orig_name,
 			mmfile_t *src1, const char *name1,
 			mmfile_t *src2, const char *name2,
 			int flag, int marker_size)
@@ -71,7 +71,8 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 			path, name1, name2);
 		return ll_binary_merge(drv_unused, result,
 				       path,
-				       orig, src1, name1,
+				       orig, orig_name,
+				       src1, name1,
 				       src2, name2,
 				       flag, marker_size);
 	}
@@ -83,6 +84,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 		xmp.style = git_xmerge_style;
 	if (marker_size > 0)
 		xmp.marker_size = marker_size;
+	xmp.ancestor = orig_name;
 	xmp.file1 = name1;
 	xmp.file2 = name2;
 	return xdl_merge(orig, src1, src2, &xmp, result);
@@ -91,7 +93,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 static int ll_union_merge(const struct ll_merge_driver *drv_unused,
 			  mmbuffer_t *result,
 			  const char *path_unused,
-			  mmfile_t *orig,
+			  mmfile_t *orig, const char *orig_name,
 			  mmfile_t *src1, const char *name1,
 			  mmfile_t *src2, const char *name2,
 			  int flag, int marker_size)
@@ -99,7 +101,7 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,
 	/* Use union favor */
 	flag = (flag & 1) | (XDL_MERGE_FAVOR_UNION << 1);
 	return ll_xdl_merge(drv_unused, result, path_unused,
-			    orig, src1, NULL, src2, NULL,
+			    orig, NULL, src1, NULL, src2, NULL,
 			    flag, marker_size);
 	return 0;
 }
@@ -130,7 +132,7 @@ static void create_temp(mmfile_t *src, char *path)
 static int ll_ext_merge(const struct ll_merge_driver *fn,
 			mmbuffer_t *result,
 			const char *path,
-			mmfile_t *orig,
+			mmfile_t *orig, const char *orig_name,
 			mmfile_t *src1, const char *name1,
 			mmfile_t *src2, const char *name2,
 			int flag, int marker_size)
@@ -321,7 +323,7 @@ static int git_path_check_merge(const char *path, struct git_attr_check check[2]
 
 int ll_merge(mmbuffer_t *result_buf,
 	     const char *path,
-	     mmfile_t *ancestor,
+	     mmfile_t *ancestor, const char *ancestor_label,
 	     mmfile_t *ours, const char *our_label,
 	     mmfile_t *theirs, const char *their_label,
 	     int flag)
@@ -343,7 +345,7 @@ int ll_merge(mmbuffer_t *result_buf,
 	driver = find_ll_merge_driver(ll_driver_name);
 	if (virtual_ancestor && driver->recursive)
 		driver = find_ll_merge_driver(driver->recursive);
-	return driver->fn(driver, result_buf, path, ancestor,
+	return driver->fn(driver, result_buf, path, ancestor, ancestor_label,
 			  ours, our_label, theirs, their_label,
 			  flag, marker_size);
 }
diff --git a/ll-merge.h b/ll-merge.h
index 5788922..57754cc 100644
--- a/ll-merge.h
+++ b/ll-merge.h
@@ -7,7 +7,7 @@
 
 int ll_merge(mmbuffer_t *result_buf,
 	     const char *path,
-	     mmfile_t *ancestor,
+	     mmfile_t *ancestor, const char *ancestor_label,
 	     mmfile_t *ours, const char *our_label,
 	     mmfile_t *theirs, const char *their_label,
 	     int flag);
diff --git a/merge-file.c b/merge-file.c
index fd34d76..07cc0c9 100644
--- a/merge-file.c
+++ b/merge-file.c
@@ -30,7 +30,7 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our
 	int merge_status;
 	mmbuffer_t res;
 
-	merge_status = ll_merge(&res, path, base,
+	merge_status = ll_merge(&res, path, base, NULL,
 				our, ".our", their, ".their", 0);
 	if (merge_status < 0)
 		return NULL;
diff --git a/merge-recursive.c b/merge-recursive.c
index 195ebf9..3b2cc9d 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -640,7 +640,7 @@ static int merge_3way(struct merge_options *o,
 	read_mmblob(&src1, a->sha1);
 	read_mmblob(&src2, b->sha1);
 
-	merge_status = ll_merge(result_buf, a->path, &orig,
+	merge_status = ll_merge(result_buf, a->path, &orig, NULL,
 				&src1, name1, &src2, name2,
 				(!!o->call_depth) | (favor << 1));
 
diff --git a/rerere.c b/rerere.c
index a59f74f..f221bed 100644
--- a/rerere.c
+++ b/rerere.c
@@ -319,7 +319,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
 		if (!mmfile[i].ptr && !mmfile[i].size)
 			mmfile[i].ptr = xstrdup("");
 	}
-	ll_merge(&result, path, &mmfile[0],
+	ll_merge(&result, path, &mmfile[0], NULL,
 		 &mmfile[1], "ours",
 		 &mmfile[2], "theirs", 0);
 	for (i = 0; i < 3; i++)
@@ -376,7 +376,7 @@ static int merge(const char *name, const char *path)
 		ret = 1;
 		goto out;
 	}
-	ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0);
+	ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
 	if (!ret) {
 		FILE *f = fopen(path, "w");
 		if (!f)
-- 
1.7.0.2

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

* [PATCH 07/14] checkout --conflict=diff3: add a label for ancestor
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (5 preceding siblings ...)
  2010-03-21  0:38   ` [PATCH 06/14] ll_merge(): add ancestor label parameter for diff3-style output Jonathan Nieder
@ 2010-03-21  0:40   ` Jonathan Nieder
  2010-03-21  0:40   ` [PATCH 08/14] merge_file(): add comment explaining behavior wrt conflict style Jonathan Nieder
                     ` (6 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:40 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

git checkout --conflict=diff3 can be used to present conflicts hunks
including text from the common ancestor:

	<<<<<<< ours
	ourside
	|||||||
	original
	=======
	theirside
	>>>>>>> theirs

The added information is helpful for resolving a merge by hand, and
merge tools can usually understand it without trouble because it looks
like output from ‘diff3 -m’.

diff3 includes a label for the merge base on the ||||||| line, and it
seems some tools (for example, Emacs 22’s smerge-mode) cannot parse
conflict hunks without such a label.  Humans could use help in
interpreting the output, too.  So change the marker for the start of the
text from the common ancestor to include the label “base”.

git rerere’s conflict identifiers are not affected: to parse conflict
hunks, rerere looks for whitespace after the ||||||| marker rather
than a newline, and to compute preimage ids, rerere has its own code
for creating conflict hunks.  No other code in git tries to parse
conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142380>.

 builtin/checkout.c |    2 +-
 t/t7201-co.sh      |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index d67f809..d652b4c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	read_mmblob(&ours, active_cache[pos+1]->sha1);
 	read_mmblob(&theirs, active_cache[pos+2]->sha1);
 
-	status = ll_merge(&result_buf, path, &ancestor, NULL,
+	status = ll_merge(&result_buf, path, &ancestor, "base",
 			  &ours, "ours", &theirs, "theirs", 0);
 	free(ancestor.ptr);
 	free(ours.ptr);
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 01175f7..f3f0c4c 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -538,7 +538,7 @@ test_expect_success 'checkout with --merge, in diff3 -m style' '
 	(
 		echo "<<<<<<< ours"
 		echo ourside
-		echo "|||||||"
+		echo "||||||| base"
 		echo original
 		echo "======="
 		echo theirside
@@ -582,7 +582,7 @@ test_expect_success 'checkout --conflict=diff3' '
 	(
 		echo "<<<<<<< ours"
 		echo ourside
-		echo "|||||||"
+		echo "||||||| base"
 		echo original
 		echo "======="
 		echo theirside
-- 
1.7.0.2

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

* [PATCH 08/14] merge_file(): add comment explaining behavior wrt conflict style
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (6 preceding siblings ...)
  2010-03-21  0:40   ` [PATCH 07/14] checkout --conflict=diff3: add a label for ancestor Jonathan Nieder
@ 2010-03-21  0:40   ` Jonathan Nieder
  2010-03-21  0:41   ` [PATCH 09/14] merge_trees(): add ancestor label parameter for diff3-style output Jonathan Nieder
                     ` (5 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:40 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

The merge_file() function is a helper for ‘git read-tree’, which does
not respect the merge.conflictstyle option, so there is no need to
worry about what ancestor_name it should pass to ll_merge().  Add a
comment to this effect.

Signed-off-by: Jonathan Nieder <jrnieder@mgila.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142381>.

 merge-file.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/merge-file.c b/merge-file.c
index 07cc0c9..c336c93 100644
--- a/merge-file.c
+++ b/merge-file.c
@@ -30,6 +30,12 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our
 	int merge_status;
 	mmbuffer_t res;
 
+	/*
+	 * This function is only used by cmd_merge_tree, which
+	 * does not respect the merge.conflictstyle option.
+	 * There is no need to worry about a label for the
+	 * common ancestor.
+	 */
 	merge_status = ll_merge(&res, path, base, NULL,
 				our, ".our", their, ".their", 0);
 	if (merge_status < 0)
-- 
1.7.0.2

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

* [PATCH 09/14] merge_trees(): add ancestor label parameter for diff3-style output
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (7 preceding siblings ...)
  2010-03-21  0:40   ` [PATCH 08/14] merge_file(): add comment explaining behavior wrt conflict style Jonathan Nieder
@ 2010-03-21  0:41   ` Jonathan Nieder
  2010-03-21  0:42   ` [PATCH 10/14] checkout -m --conflict=diff3: add a label for ancestor Jonathan Nieder
                     ` (4 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:41 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

Commands using the merge_trees() machinery will present conflict hunks
in output something like what ‘diff3 -m’ produces if the
merge.conflictstyle configuration option is set to diff3.  The output
lacks the name of the merge base on the ||||||| line of the output,
and tools can misparse the conflict hunks without it.  Add a new
o->ancestor parameter to merge_trees() for use as a label for the
ancestor in conflict hunks.

If o->ancestor is NULL, the output format is as before.  All callers
pass NULL for now.

If o->ancestor is non-NULL and both branches renamed the base file
to the same name, that name is included in the conflict hunk labels.
Even if o->ancestor is NULL I think this would be a good change, but
this patch only does it in the non-NULL case to ensure the output
format does not change where it might matter.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142382>.

 merge-recursive.c |   11 ++++++++---
 merge-recursive.h |    1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 3b2cc9d..017cafd 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -608,7 +608,7 @@ static int merge_3way(struct merge_options *o,
 		      const char *branch2)
 {
 	mmfile_t orig, src1, src2;
-	char *name1, *name2;
+	char *base_name, *name1, *name2;
 	int merge_status;
 	int favor;
 
@@ -628,10 +628,15 @@ static int merge_3way(struct merge_options *o,
 		}
 	}
 
-	if (strcmp(a->path, b->path)) {
+	if (strcmp(a->path, b->path) ||
+	    (o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
+		base_name = o->ancestor == NULL ? NULL :
+			xstrdup(mkpath("%s:%s", o->ancestor, one->path));
 		name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
 		name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
 	} else {
+		base_name = o->ancestor == NULL ? NULL :
+			xstrdup(mkpath("%s", o->ancestor));
 		name1 = xstrdup(mkpath("%s", branch1));
 		name2 = xstrdup(mkpath("%s", branch2));
 	}
@@ -640,7 +645,7 @@ static int merge_3way(struct merge_options *o,
 	read_mmblob(&src1, a->sha1);
 	read_mmblob(&src2, b->sha1);
 
-	merge_status = ll_merge(result_buf, a->path, &orig, NULL,
+	merge_status = ll_merge(result_buf, a->path, &orig, base_name,
 				&src1, name1, &src2, name2,
 				(!!o->call_depth) | (favor << 1));
 
diff --git a/merge-recursive.h b/merge-recursive.h
index be8410a..d1192f5 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -4,6 +4,7 @@
 #include "string-list.h"
 
 struct merge_options {
+	const char *ancestor;
 	const char *branch1;
 	const char *branch2;
 	enum {
-- 
1.7.0.2

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

* [PATCH 10/14] checkout -m --conflict=diff3: add a label for ancestor
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (8 preceding siblings ...)
  2010-03-21  0:41   ` [PATCH 09/14] merge_trees(): add ancestor label parameter for diff3-style output Jonathan Nieder
@ 2010-03-21  0:42   ` Jonathan Nieder
  2010-03-21  0:43   ` [PATCH 11/14] compat: add mempcpy() Jonathan Nieder
                     ` (3 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:42 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

git checkout --merge --conflict=diff3 can be used to present conflict
hunks including text from the common ancestor.  The added information
is helpful for resolving a merge by hand, and merge tools tend to
understand it because it is very similar to what ‘diff3 -m’ produces.

Unlike current git, diff3 -m includes a label for the merge base on
the ||||||| line, and unfortunately, some tools cannot parse the
conflict hunks without it.  Humans can benefit from a cue when
learning to interpreting the format, too.  Mark the start of the text
from the old branch with a label based on the branch’s name.

git rerere does not have trouble parsing this output and its preimage
ids are unchanged since it includes its own code for recreating
conflict hunks.  No other code in git tries to parse conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142384>.

 builtin/checkout.c |    1 +
 t/t7201-co.sh      |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index d652b4c..88b1f43 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -439,6 +439,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 			ret = reset_tree(new->commit->tree, opts, 1);
 			if (ret)
 				return ret;
+			o.ancestor = old->name;
 			o.branch1 = new->name;
 			o.branch2 = "local";
 			merge_trees(&o, new->commit->tree, work,
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index f3f0c4c..1337fa5 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -209,7 +209,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
 	a
 	c
 	e
-	|||||||
+	||||||| master
 	a
 	b
 	c
-- 
1.7.0.2

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

* [PATCH 11/14] compat: add mempcpy()
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (9 preceding siblings ...)
  2010-03-21  0:42   ` [PATCH 10/14] checkout -m --conflict=diff3: add a label for ancestor Jonathan Nieder
@ 2010-03-21  0:43   ` Jonathan Nieder
  2010-03-21  0:45   ` [PATCH 12/14] revert: clarify label on conflict hunks Jonathan Nieder
                     ` (2 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:43 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

The mempcpy() function was added in glibc 2.1.  It is quite handy, so
add an implementation for cross-platform use.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142387>.

 git-compat-util.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index a3c4537..9bed5a0 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -331,6 +331,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,
 #ifdef __GLIBC_PREREQ
 #if __GLIBC_PREREQ(2, 1)
 #define HAVE_STRCHRNUL
+#define HAVE_MEMPCPY
 #endif
 #endif
 
@@ -344,6 +345,14 @@ static inline char *gitstrchrnul(const char *s, int c)
 }
 #endif
 
+#ifndef HAVE_MEMPCPY
+#define mempcpy gitmempcpy
+static inline void *gitmempcpy(void *dest, const void *src, size_t n)
+{
+	return (char *)memcpy(dest, src, n) + n;
+}
+#endif
+
 extern void release_pack_memory(size_t, int);
 
 extern char *xstrdup(const char *str);
-- 
1.7.0.2

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

* [PATCH 12/14] revert: clarify label on conflict hunks
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (10 preceding siblings ...)
  2010-03-21  0:43   ` [PATCH 11/14] compat: add mempcpy() Jonathan Nieder
@ 2010-03-21  0:45   ` Jonathan Nieder
  2010-03-21  0:46   ` [PATCH 13/14] cherry-pick, revert: add a label for ancestor Jonathan Nieder
  2010-03-21  0:52   ` [PATCH 14/14] merge-recursive: " Jonathan Nieder
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:45 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg, Stephen Boyd

When reverting a commit, the commit being merged is not the commit
to revert itself but its parent.  Add “parent of” to the conflict
hunk label to make this more clear.

The conflict hunk labels are all pieces of a single string written in
the new get_message() function.  Avoid some complication by using
mempcpy to advance a pointer as the result is written.

Also free the corresponding temporary buffer (it was leaked before).
This is not important because it is a small one-time allocation.  It
would become a memory leak if unnoticed when libifying revert.

This patch uses calls to strlen() instead of integer constants in some
places.  GCC will compute the length at compile time; I am not sure
about other compilers, but this is not performance-critical anyway.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142448>.

Thanks to Stephen for advice.

 builtin/revert.c                |  100 ++++++++++++++++++++++++---------------
 t/t3507-cherry-pick-conflict.sh |    4 +-
 2 files changed, 63 insertions(+), 41 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index eff5268..b314629 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -45,6 +45,8 @@ static const char *me;
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
+static char *get_encoding(const char *message);
+
 static void parse_args(int argc, const char **argv)
 {
 	const char * const * usage_str =
@@ -73,33 +75,63 @@ static void parse_args(int argc, const char **argv)
 		exit(1);
 }
 
-static char *get_oneline(const char *message)
+struct commit_message {
+	char *parent_label;
+	const char *label;
+	const char *subject;
+	char *reencoded_message;
+	const char *message;
+};
+
+static int get_message(const char *raw_message, struct commit_message *out)
 {
-	char *result;
-	const char *p = message, *abbrev, *eol;
+	const char *encoding;
+	const char *p, *abbrev, *eol;
+	char *q;
 	int abbrev_len, oneline_len;
 
-	if (!p)
-		die ("Could not read commit message of %s",
-				sha1_to_hex(commit->object.sha1));
+	if (!raw_message)
+		return -1;
+	encoding = get_encoding(raw_message);
+	if (!encoding)
+		encoding = "UTF-8";
+	if (!git_commit_encoding)
+		git_commit_encoding = "UTF-8";
+	if ((out->reencoded_message = reencode_string(raw_message,
+					git_commit_encoding, encoding)))
+		out->message = out->reencoded_message;
+
+	abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
+	abbrev_len = strlen(abbrev);
+
+	/* Find beginning and end of commit subject. */
+	p = out->message;
 	while (*p && (*p != '\n' || p[1] != '\n'))
 		p++;
-
 	if (*p) {
 		p += 2;
 		for (eol = p + 1; *eol && *eol != '\n'; eol++)
 			; /* do nothing */
 	} else
 		eol = p;
-	abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
-	abbrev_len = strlen(abbrev);
 	oneline_len = eol - p;
-	result = xmalloc(abbrev_len + 5 + oneline_len);
-	memcpy(result, abbrev, abbrev_len);
-	memcpy(result + abbrev_len, "... ", 4);
-	memcpy(result + abbrev_len + 4, p, oneline_len);
-	result[abbrev_len + 4 + oneline_len] = '\0';
-	return result;
+
+	out->parent_label = xmalloc(strlen("parent of ") + abbrev_len +
+			      strlen("... ") + oneline_len + 1);
+	q = out->parent_label;
+	q = mempcpy(q, "parent of ", strlen("parent of "));
+	out->label = q;
+	q = mempcpy(q, abbrev, abbrev_len);
+	q = mempcpy(q, "... ", strlen("... "));
+	out->subject = q;
+	q = mempcpy(q, p, oneline_len);
+	*q = '\0';
+	return 0;
+}
+
+static void free_message(struct commit_message *msg) {
+	free(msg->parent_label);
+	free(msg->reencoded_message);
 }
 
 static char *get_encoding(const char *message)
@@ -248,9 +280,10 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 {
 	unsigned char head[20];
 	struct commit *base, *next, *parent;
+	const char *next_label;
 	int i, index_fd, clean;
-	char *oneline, *reencoded_message = NULL;
-	const char *message, *encoding;
+	struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
+
 	char *defmsg = git_pathdup("MERGE_MSG");
 	struct merge_options o;
 	struct tree *result, *next_tree, *base_tree, *head_tree;
@@ -314,14 +347,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	else
 		parent = commit->parents->item;
 
-	if (!(message = commit->buffer))
-		die ("Cannot get commit message for %s",
-				sha1_to_hex(commit->object.sha1));
-
 	if (parent && parse_commit(parent) < 0)
 		die("%s: cannot parse parent commit %s",
 		    me, sha1_to_hex(parent->object.sha1));
 
+	if (get_message(commit->buffer, &msg) != 0)
+		die ("Cannot get commit message for %s",
+				sha1_to_hex(commit->object.sha1));
+
 	/*
 	 * "commit" is an existing commit.  We would want to apply
 	 * the difference it introduces since its first parent "prev"
@@ -332,24 +365,12 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
 					   LOCK_DIE_ON_ERROR);
 
-	encoding = get_encoding(message);
-	if (!encoding)
-		encoding = "UTF-8";
-	if (!git_commit_encoding)
-		git_commit_encoding = "UTF-8";
-	if ((reencoded_message = reencode_string(message,
-					git_commit_encoding, encoding)))
-		message = reencoded_message;
-
-	oneline = get_oneline(message);
-
 	if (action == REVERT) {
-		char *oneline_body = strchr(oneline, ' ');
-
 		base = commit;
 		next = parent;
+		next_label = msg.parent_label;
 		add_to_msg("Revert \"");
-		add_to_msg(oneline_body + 1);
+		add_to_msg(msg.subject);
 		add_to_msg("\"\n\nThis reverts commit ");
 		add_to_msg(sha1_to_hex(commit->object.sha1));
 
@@ -361,8 +382,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	} else {
 		base = parent;
 		next = commit;
-		set_author_ident_env(message);
-		add_message_to_msg(message);
+		next_label = msg.label;
+		set_author_ident_env(msg.message);
+		add_message_to_msg(msg.message);
 		if (no_replay) {
 			add_to_msg("(cherry picked from commit ");
 			add_to_msg(sha1_to_hex(commit->object.sha1));
@@ -373,7 +395,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 	read_cache();
 	init_merge_options(&o);
 	o.branch1 = "HEAD";
-	o.branch2 = oneline;
+	o.branch2 = next ? next_label : "(empty tree)";
 
 	head_tree = parse_tree_indirect(head);
 	next_tree = next ? next->tree : empty_tree();
@@ -437,7 +459,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		args[i] = NULL;
 		return execv_git_cmd(args);
 	}
-	free(reencoded_message);
+	free_message(&msg);
 	free(defmsg);
 
 	return 0;
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index e856356..6a20817 100644
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -138,7 +138,7 @@ test_expect_success 'revert also handles conflicts sanely' '
 	a
 	=======
 	b
-	>>>>>>> objid picked
+	>>>>>>> parent of objid picked
 	EOF
 	{
 		git checkout picked -- foo &&
@@ -183,7 +183,7 @@ test_expect_success 'revert conflict, diff3 -m style' '
 	c
 	=======
 	b
-	>>>>>>> objid picked
+	>>>>>>> parent of objid picked
 	EOF
 
 	git update-index --refresh &&
-- 
1.7.0.2

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

* [PATCH 13/14] cherry-pick, revert: add a label for ancestor
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (11 preceding siblings ...)
  2010-03-21  0:45   ` [PATCH 12/14] revert: clarify label on conflict hunks Jonathan Nieder
@ 2010-03-21  0:46   ` Jonathan Nieder
  2010-03-21  0:52   ` [PATCH 14/14] merge-recursive: " Jonathan Nieder
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:46 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

When writing conflict hunks in ‘diff3 -m’ format, also add a label to
the common ancestor.  Especially in a cherry-pick, it is not immediately
obvious without such a label what the common ancestor represents.

git rerere does not have trouble parsing the new output and its preimage
ids are unchanged since it includes its own code for recreating conflict
hunks.  No other code in git parses conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142449>.

 builtin/revert.c                |    5 ++++-
 t/t3507-cherry-pick-conflict.sh |    4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index b314629..625281c 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -280,7 +280,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 {
 	unsigned char head[20];
 	struct commit *base, *next, *parent;
-	const char *next_label;
+	const char *base_label, *next_label;
 	int i, index_fd, clean;
 	struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
 
@@ -367,6 +367,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 
 	if (action == REVERT) {
 		base = commit;
+		base_label = msg.label;
 		next = parent;
 		next_label = msg.parent_label;
 		add_to_msg("Revert \"");
@@ -381,6 +382,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		add_to_msg(".\n");
 	} else {
 		base = parent;
+		base_label = msg.parent_label;
 		next = commit;
 		next_label = msg.label;
 		set_author_ident_env(msg.message);
@@ -394,6 +396,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 
 	read_cache();
 	init_merge_options(&o);
+	o.ancestor = base ? base_label : "(empty tree)";
 	o.branch1 = "HEAD";
 	o.branch2 = next ? next_label : "(empty tree)";
 
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index 6a20817..e25cf80 100644
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -112,7 +112,7 @@ test_expect_success 'diff3 -m style' '
 	cat <<-EOF > expected &&
 	<<<<<<< HEAD
 	a
-	|||||||
+	||||||| parent of objid picked
 	b
 	=======
 	c
@@ -179,7 +179,7 @@ test_expect_success 'revert conflict, diff3 -m style' '
 	cat <<-EOF > expected &&
 	<<<<<<< HEAD
 	a
-	|||||||
+	||||||| objid picked
 	c
 	=======
 	b
-- 
1.7.0.2

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

* [PATCH 14/14] merge-recursive: add a label for ancestor
  2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
                     ` (12 preceding siblings ...)
  2010-03-21  0:46   ` [PATCH 13/14] cherry-pick, revert: add a label for ancestor Jonathan Nieder
@ 2010-03-21  0:52   ` Jonathan Nieder
  13 siblings, 0 replies; 16+ messages in thread
From: Jonathan Nieder @ 2010-03-21  0:52 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Bert Wesarg

git merge-recursive (and hence git merge) will present conflict hunks
in output something like what ‘diff3 -m’ produces if the
merge.conflictstyle configuration option is set to diff3.
There is a small difference from diff3: diff3 -m includes a label
for the merge base on the ||||||| line.

Tools familiar with the format and humans unfamiliar with the format
both can benefit from such a label.  So mark the start of the text
from the merge bases with the heading "||||||| merged common
ancestors".

It would be nicer to use a more informative label.  Perhaps someone
will provide one some day.

git rerere does not have trouble parsing the new output, and its
preimage ids are unchanged since it has its own code for re-creating
conflict hunks.  No other code in git parses conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
From <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142391>.

The new series has a small conflict with ‘next’ (the cherry-pick --no-ff
change).  I’ll try resolving it and put up the result at

 git://repo.or.cz/git/jrn.git merge-diff3-label/for-next

 merge-recursive.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 017cafd..917397c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1347,6 +1347,7 @@ int merge_recursive(struct merge_options *o,
 	if (!o->call_depth)
 		read_cache();
 
+	o->ancestor = "merged common ancestors";
 	clean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,
 			    &mrtree);
 
-- 
1.7.0.2

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

end of thread, other threads:[~2010-03-21  0:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-20 21:00 What's cooking in git.git (Mar 2010, #05; Sat, 20) Junio C Hamano
2010-03-21  0:25 ` [PATCH 0/14] jn/merge-diff3-label Jonathan Nieder
2010-03-21  0:27   ` [PATCH 01/14] tests: document format of conflicts from checkout -m Jonathan Nieder
2010-03-21  0:28   ` [PATCH 02/14] tests: document cherry-pick behavior in face of conflicts Jonathan Nieder
2010-03-21  0:31   ` [PATCH 03/14] xdl_merge(): add optional ancestor label to diff3-style output Jonathan Nieder
2010-03-21  0:35   ` [PATCH 04/14] xdl_merge(): move file1 and file2 labels to xmparam structure Jonathan Nieder
2010-03-21  0:37   ` [PATCH 05/14] merge-file --diff3: add a label for ancestor Jonathan Nieder
2010-03-21  0:38   ` [PATCH 06/14] ll_merge(): add ancestor label parameter for diff3-style output Jonathan Nieder
2010-03-21  0:40   ` [PATCH 07/14] checkout --conflict=diff3: add a label for ancestor Jonathan Nieder
2010-03-21  0:40   ` [PATCH 08/14] merge_file(): add comment explaining behavior wrt conflict style Jonathan Nieder
2010-03-21  0:41   ` [PATCH 09/14] merge_trees(): add ancestor label parameter for diff3-style output Jonathan Nieder
2010-03-21  0:42   ` [PATCH 10/14] checkout -m --conflict=diff3: add a label for ancestor Jonathan Nieder
2010-03-21  0:43   ` [PATCH 11/14] compat: add mempcpy() Jonathan Nieder
2010-03-21  0:45   ` [PATCH 12/14] revert: clarify label on conflict hunks Jonathan Nieder
2010-03-21  0:46   ` [PATCH 13/14] cherry-pick, revert: add a label for ancestor Jonathan Nieder
2010-03-21  0:52   ` [PATCH 14/14] merge-recursive: " Jonathan Nieder

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).