{"thread":{"id":"23113","subject":"What's cooking in git.git (Mar 2010, #05; Sat, 20)","startedAt":"2010-03-20T21:00:45Z","lastAt":"2010-03-21T00:52:21Z","messageCount":16,"participants":["Junio C Hamano","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137373","messageId":"7vr5ne908y.fsf@alter.siamese.dyndns.org","threadId":"23113","inReplyTo":null,"subject":"What's cooking in git.git (Mar 2010, #05; Sat, 20)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-20T21:00:45Z","receivedAt":"2010-03-20T21:00:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here are the topics that have been cooking.  Commits prefixed with '-' are\nonly in 'pu' while commits prefixed with '+' are in 'next'.  The ones\nmarked with '.' do not appear in any of the integration branches, but I am\nstill holding onto them.\n\n--------------------------------------------------\n[Graduated to \"master\"]\n\n* jk/maint-add-ignored-dir (2010-02-28) 3 commits\n  (merged to 'next' on 2010-03-13 at df91e32)\n + tests for \"git add ignored-dir/file\" without -f\n + dir: fix COLLECT_IGNORED on excluded prefixes\n + t0050: mark non-working test as such\n\nThis replaced jc/maint-add-ignored-dir.  Will need to merge to maint\nlater.\n\n* bg/apply-fix-blank-at-eof (2010-03-06) 5 commits\n  (merged to 'next' on 2010-03-07 at daec679)\n + t3417: Add test cases for \"rebase --whitespace=fix\"\n + t4124: Add additional tests of --whitespace=fix\n + apply: Allow blank context lines to match beyond EOF\n + apply: Remove the quick rejection test\n + apply: Don't unnecessarily update line lengths in the preimage\n\n* fl/askpass (2010-03-04) 2 commits\n  (merged to 'next' on 2010-03-07 at 5ab370a)\n + git-core: Support retrieving passwords with GIT_ASKPASS\n + git-svn: Support retrieving passwords with GIT_ASKPASS\n\n* jc/color-attrs (2010-02-27) 1 commit\n  (merged to 'next' on 2010-03-08 at ba02883)\n + color: allow multiple attributes\n\n* ml/color-grep (2010-03-07) 3 commits\n  (merged to 'next' on 2010-03-08 at 24d1eb4)\n + grep: Colorize selected, context, and function lines\n + grep: Colorize filename, line number, and separator\n + Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*\n\n* bw/union-merge-refactor (2010-03-01) 4 commits\n  (merged to 'next' on 2010-03-10 at b917078)\n + merge-file: add option to select union merge favor\n + merge-file: add option to specify the marker size\n  (merged to 'next' on 2010-03-07 at 9d1eff6)\n + refactor merge flags into xmparam_t\n + make union merge an xdl merge favor\n\n* cc/reset-keep (2010-03-09) 6 commits\n  (merged to 'next' on 2010-03-08 at 015ef4b)\n + Documentation: improve description of \"git reset --keep\"\n  (merged to 'next' on 2010-03-07 at 5237d8e)\n + reset: disallow using --keep when there are unmerged entries\n + reset: disallow \"reset --keep\" outside a work tree\n + Documentation: reset: describe new \"--keep\" option\n + reset: add test cases for \"--keep\" option\n + reset: add option \"--keep\" to \"git reset\"\n\n--------------------------------------------------\n[New Topics]\n\n* ar/config-from-command-line (2010-03-19) 1 commit\n - Allow passing of configuration parameters in the command line\n\n* bc/t5505-fix (2010-03-19) 3 commits\n - t/t5505-remote.sh: escape * to prevent interpretation by shell as glob\n - t5505: add missing &&\n - t5505: remove unnecessary subshell invocations\n\nLooked reasonable.  Soon in 'next'.\n\n* bw/template-tool-buildconfig (2010-03-20) 2 commits\n - Modernize git calling conventions in hook templates\n - Make templates honour SHELL_PATH and PERL_PATH\n\nLooked reasonable.  Soon in 'next'.\n\n* mb/rebase-i-no-ff (2010-03-16) 1 commit\n - Teach --no-ff option to 'rebase -i'.\n\nLooked reasonable.  Soon in 'next'.\n\n* jn/merge-diff3-label (2010-03-17) 13 commits\n . cherry-pick, revert: add a label for ancestor\n . revert: clarify label on conflict hunks\n . compat: add mempcpy()\n . tests: document cherry-pick behavior in face of conflicts\n . checkout -m --conflict=diff3: add a label for ancestor\n . tests: document format of conflicts from checkout -m\n . merge_trees(): add ancestor label parameter for diff3-style output\n . merge_file(): add comment explaining behavior wrt conflict style\n . checkout --conflict=diff3: add a label for ancestor\n . ll_merge(): add ancestor label parameter for diff3-style output\n . merge-file --diff3: add a label for ancestor\n . xdl_merge(): move file1 and file2 labels to xmparam structure\n . xdl_merge(): add optional ancestor label to diff3-style output\n\nThis somewhat conflicts with bw/union-merge-refactor that in 'master'; I\ncould resolve the conflicts myself, but I'd rather not.  Jonathan, could\nyou rebase the series?\n\n--------------------------------------------------\n[Stalled]\n\n* cw/test-lib-relicense (2010-02-22) 1 commit\n . test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.\n\nAck-collection stopped at the last three names.  I am hoping Carl can take\nit from there without my keeping an eye on it.\n\n* js/rebase-origin-x (2010-02-05) 1 commit\n - [RFC w/o test and incomplete] rebase: add -x option to record original commit name\n\nI retract my objection against the idea of -x; needs polishing before\nmoving forward.\n\n* sg/bash-completion (2010-02-23) 4 commits\n  (merged to 'next' on 2010-03-08 at bc59860)\n + bash: completion for gitk aliases\n + bash: support user-supplied completion scripts for aliases\n + bash: support user-supplied completion scripts for user's git commands\n + bash: improve aliased command recognition\n\nPerhaps rename _git_frotz -> _git_complete_frotz?  I dunno.\n\n* sd/log-decorate (2010-02-17) 3 commits\n  (merged to 'next' on 2010-03-08 at 58a6fba)\n + log.decorate: usability fixes\n + Add `log.decorate' configuration variable.\n + git_config_maybe_bool()\n\nNeeds squelching the configuration setting when \"--pretty=raw\" is given,\nat least, or possibly when any \"--pretty\" is explicitly given.\n\n--------------------------------------------------\n[Cooking]\n\n* do/rebase-i-arbitrary (2010-03-14) 1 commit\n - rebase--interactive: don't require what's rebased to be a branch\n\nLooked reasonable.  Soon in 'next'.\n\n* ja/send-email-ehlo (2010-03-14) 3 commits\n - git-send-email.perl - try to give real name of the calling host to HELO/EHLO\n - git-send-email.perl: add option --smtp-debug\n - git-send-email.perl: improve error message in send_message()\n\nLooked reasonable.  Soon in 'next'.\n\n* ak/everyday-git (2009-10-21) 1 commit\n - everyday: fsck and gc are not everyday operations\n\nLooked reasonable.  Soon in 'next'.\n\n* bc/acl-test (2010-03-15) 5 commits\n - t/t1304: make a second colon optional in the mask ACL check\n - t/t1304: set the ACL effective rights mask\n - t/t1304: use 'test -r' to test readability rather than looking at mode bits\n - t/t1304: set the Default ACL base entries\n - t/t1304: avoid -d option to setfacl\n\nLooked reasonable.  Soon in 'next'.\n\n* bc/maint-daemon-sans-ss-family (2010-03-15) 1 commit\n - daemon.c: avoid accessing ss_family member of struct sockaddr_storage\n\nLooked reasonable.  Soon in 'next'.\n\n* ef/cherry-abbrev (2010-03-15) 1 commit\n - cherry: support --abbrev option\n\nLooked reasonable.  Soon in 'next'.\n\n* gh/maint-stash-show-error-message (2010-03-16) 1 commit\n - Improve error messages from 'git stash show'\n\nLooked reasonable.  Soon in 'next'.\n\n* jc/maint-refs-dangling (2010-03-15) 1 commit\n  (merged to 'next' on 2010-03-16 at 376027b)\n + refs: ref entry with NULL sha1 is can be a dangling symref\n\nLooked reasonable.  Soon in 'next'.\n\n* rs/threaded-grep-context (2010-03-15) 1 commit\n - grep: enable threading for context line printing\n\nLooked reasonable.  Soon in 'next'.\n\n* pb/log-first-parent-p-m (2010-03-09) 5 commits\n  (merged to 'next' on 2010-03-15 at 0ae494e)\n + show --first-parent/-m: do not default to --cc\n + show -c: show patch text\n + revision: introduce setup_revision_opt\n + t4013: add tests for log -p -m --first-parent\n  (merged to 'next' on 2010-02-17 at 2f8e5ae)\n + git log -p -m: document -m and honor --first-parent\n\nReady for 'master'.\n\n* jl/submodule-diff-dirtiness (2010-03-13) 5 commits\n  (merged to 'next' on 2010-03-15 at 9601fd9)\n + git status: ignoring untracked files must apply to submodules too\n  (merged to 'next' on 2010-03-13 at f9bfd8a)\n + git status: Fix false positive \"new commits\" output for dirty submodules\n + Refactor dirty submodule detection in diff-lib.c\n  (merged to 'next' on 2010-03-08 at 33f7a57)\n + git status: Show detailed dirty status of submodules in long format\n  (merged to 'next' on 2010-03-04 at 58b2645)\n + git diff --submodule: Show detailed dirty status of submodules\n\nReady for 'master'.\n\n* cc/cherry-pick-ff (2010-03-06) 6 commits\n  (merged to 'next' on 2010-03-20 at fdfcd14)\n + rebase -i: use new --ff cherry-pick option\n  (merged to 'next' on 2010-03-07 at 5589b26)\n + Documentation: describe new cherry-pick --ff option\n + cherry-pick: add tests for new --ff option\n + revert: add --ff option to allow fast forward when cherry-picking\n + builtin/merge: make checkout_fast_forward() non static\n + parse-options: add parse_options_concat() to concat options\n\nReady for 'master'.\n\n* js/async-thread (2010-03-09) 7 commits\n - Enable threaded async procedures whenever pthreads is available\n  (merged to 'next' on 2010-03-20 at 9939243)\n + Dying in an async procedure should only exit the thread, not the process.\n + Reimplement async procedures using pthreads\n + Windows: more pthreads functions\n + Fix signature of fcntl() compatibility dummy\n + Make report() from usage.c public as vreportf() and use it.\n + Modernize t5530-upload-pack-error.\n\nThe tip one will be soon in 'next', but one step at a time.\n\n* nd/setup (2010-03-08) 21 commits\n - index-pack: use RUN_SETUP_GENTLY\n - index-pack: trust the prefix returned by setup_git_directory_gently()\n - worktree setup: calculate prefix even if no worktree is found\n - merge-file: use RUN_SETUP_GENTLY\n - var: use RUN_SETUP_GENTLY\n - ls-remote: use RUN_SETUP_GENTLY\n - help: use RUN_SETUP_GENTLY\n - diff: use RUN_SETUP_GENTLY\n - bundle: use RUN_SETUP_GENTLY\n - apply: use RUN_SETUP_GENTLY\n - verify-pack: use RUN_SETUP_GENTLY\n - check-ref-format: use RUN_SETUP_GENTLY\n - mailinfo: use RUN_SETUP_GENTLY\n - archive: use RUN_SETUP_GENTLY\n - builtin: USE_PAGER should not be used without RUN_SETUP*\n - grep: use RUN_SETUP_GENTLY\n - shortlog: use RUN_SETUP_GENTLY\n - hash-object: use RUN_SETUP_GENTLY\n - config: use RUN_SETUP_GENTLY\n - builtin: Support RUN_SETUP_GENTLY to set up repository early if found\n - builtin: introduce startup_info struct\n\n* sb/notes-parse-opt (2010-02-27) 1 commit\n - notes: rework subcommands and parse options\n (this branch uses tr/notes-display.)\n\n* jh/maint-submodule-status-in-void (2010-03-09) 2 commits\n  (merged to 'next' on 2010-03-15 at 49af9de)\n + git submodule summary: Handle HEAD as argument when on an unborn branch\n  (merged to 'next' on 2010-03-08 at 0697bf4)\n + submodule summary: do not fail before the first commit\n\n* tr/notes-display (2010-03-12) 13 commits\n  (merged to 'next' on 2010-03-15 at 3329361)\n + git-notes(1): add a section about the meaning of history\n + notes: track whether notes_trees were changed at all\n + notes: add shorthand --ref to override GIT_NOTES_REF\n + commit --amend: copy notes to the new commit\n + rebase: support automatic notes copying\n + notes: implement helpers needed for note copying during rewrite\n + notes: implement 'git notes copy --stdin'\n + rebase -i: invoke post-rewrite hook\n + rebase: invoke post-rewrite hook\n + commit --amend: invoke post-rewrite hook\n + Documentation: document post-rewrite hook\n + Support showing notes from more than one notes tree\n + test-lib: unset GIT_NOTES_REF to stop it from influencing tests\n (this branch is used by sb/notes-parse-opt.)\n"},{"id":"137387","messageId":"20100321002535.GA23681@progeny.tock","threadId":"23113","inReplyTo":"7vr5ne908y.fsf@alter.siamese.dyndns.org","subject":"[PATCH 0/14] jn/merge-diff3-label","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:25:36Z","receivedAt":"2010-03-21T00:25:36Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> * jn/merge-diff3-label (2010-03-17) 13 commits\n>  . cherry-pick, revert: add a label for ancestor\n>  . revert: clarify label on conflict hunks\n>  . compat: add mempcpy()\n>  . tests: document cherry-pick behavior in face of conflicts\n>  . checkout -m --conflict=diff3: add a label for ancestor\n>  . tests: document format of conflicts from checkout -m\n>  . merge_trees(): add ancestor label parameter for diff3-style output\n>  . merge_file(): add comment explaining behavior wrt conflict style\n>  . checkout --conflict=diff3: add a label for ancestor\n>  . ll_merge(): add ancestor label parameter for diff3-style output\n>  . merge-file --diff3: add a label for ancestor\n>  . xdl_merge(): move file1 and file2 labels to xmparam structure\n>  . xdl_merge(): add optional ancestor label to diff3-style output\n> \n> This somewhat conflicts with bw/union-merge-refactor that in 'master'; I\n> could resolve the conflicts myself, but I'd rather not.  Jonathan, could\n> you rebase the series?\n\nSure thing.  Here is the latest verison.\n\nJonathan Nieder (14):\n  tests: document format of conflicts from checkout -m\n  tests: document cherry-pick behavior in face of conflicts\n  xdl_merge(): add optional ancestor label to diff3-style output\n  xdl_merge(): move file1 and file2 labels to xmparam structure\n  merge-file --diff3: add a label for ancestor\n  ll_merge(): add ancestor label parameter for diff3-style output\n  checkout --conflict=diff3: add a label for ancestor\n  merge_file(): add comment explaining behavior wrt conflict style\n  merge_trees(): add ancestor label parameter for diff3-style output\n  checkout -m --conflict=diff3: add a label for ancestor\n  compat: add mempcpy()\n  revert: clarify label on conflict hunks\n  cherry-pick, revert: add a label for ancestor\n  merge-recursive: add a label for ancestor\n\n builtin/checkout.c              |    3 +-\n builtin/merge-file.c            |    6 +-\n builtin/revert.c                |  103 +++++++++++++--------\n git-compat-util.h               |    9 ++\n ll-merge.c                      |   24 +++--\n ll-merge.h                      |    2 +-\n merge-file.c                    |    8 ++-\n merge-recursive.c               |   12 ++-\n merge-recursive.h               |    1 +\n rerere.c                        |    4 +-\n t/t3507-cherry-pick-conflict.sh |  198 +++++++++++++++++++++++++++++++++++++++\n t/t6023-merge-file.sh           |    4 +-\n t/t7201-co.sh                   |   69 ++++++++++++-\n xdiff/xdiff.h                   |    6 +-\n xdiff/xmerge.c                  |   35 +++++--\n 15 files changed, 405 insertions(+), 79 deletions(-)\n create mode 100644 t/t3507-cherry-pick-conflict.sh\n"},{"id":"137388","messageId":"20100321002717.GB23681@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 01/14] tests: document format of conflicts from checkout -m","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:27:17Z","receivedAt":"2010-03-21T00:27:17Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"We are about to change the format of the conflict hunks that ‘checkout\n--merge’ writes.  Add tests checking the current behavior first.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nUnchanged from\n<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142383>.\n\n t/t7201-co.sh |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 61 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex d20ed61..01175f7 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -11,10 +11,12 @@ Test switching across them.\n   ! [master] Initial A one, A two\n    * [renamer] Renamer R one->uno, M two\n     ! [side] Side M one, D two, A three\n-  ---\n-    + [side] Side M one, D two, A three\n-   *  [renamer] Renamer R one->uno, M two\n-  +*+ [master] Initial A one, A two\n+     ! [simple] Simple D one, M two\n+  ----\n+     + [simple] Simple D one, M two\n+    +  [side] Side M one, D two, A three\n+   *   [renamer] Renamer R one->uno, M two\n+  +*++ [master] Initial A one, A two\n \n '\n \n@@ -52,6 +54,11 @@ test_expect_success setup '\n \tgit update-index --add --remove one two three &&\n \tgit commit -m \"Side M one, D two, A three\" &&\n \n+\tgit checkout -b simple master &&\n+\trm -f one &&\n+\tfill a c e > two &&\n+\tgit commit -a -m \"Simple D one, M two\" &&\n+\n \tgit checkout master\n '\n \n@@ -166,6 +173,56 @@ test_expect_success 'checkout -m with merge conflict' '\n \t! test -s current\n '\n \n+test_expect_success 'format of merge conflict from checkout -m' '\n+\n+\tgit checkout -f master && git clean -f &&\n+\n+\tfill b d > two &&\n+\tgit checkout -m simple &&\n+\n+\tgit ls-files >current &&\n+\tfill same two two two >expect &&\n+\ttest_cmp current expect &&\n+\n+\tcat <<-EOF >expect &&\n+\t<<<<<<< simple\n+\ta\n+\tc\n+\te\n+\t=======\n+\tb\n+\td\n+\t>>>>>>> local\n+\tEOF\n+\ttest_cmp two expect\n+'\n+\n+test_expect_success 'checkout --merge --conflict=diff3 <branch>' '\n+\n+\tgit checkout -f master && git reset --hard && git clean -f &&\n+\n+\tfill b d > two &&\n+\tgit checkout --merge --conflict=diff3 simple &&\n+\n+\tcat <<-EOF >expect &&\n+\t<<<<<<< simple\n+\ta\n+\tc\n+\te\n+\t|||||||\n+\ta\n+\tb\n+\tc\n+\td\n+\te\n+\t=======\n+\tb\n+\td\n+\t>>>>>>> local\n+\tEOF\n+\ttest_cmp two expect\n+'\n+\n test_expect_success 'checkout to detach HEAD (with advice declined)' '\n \n \tgit config advice.detachedHead false &&\n-- \n1.7.0.2\n"},{"id":"137389","messageId":"20100321002813.GC23681@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 02/14] tests: document cherry-pick behavior in face of conflicts","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:28:14Z","receivedAt":"2010-03-21T00:28:14Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"We are about to change the format of the conflict hunks that\ncherry-pick and revert write.  Add tests checking the current behavior\nfirst.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142385\n\n t/t3507-cherry-pick-conflict.sh |  198 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 198 insertions(+), 0 deletions(-)\n create mode 100644 t/t3507-cherry-pick-conflict.sh\n\ndiff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh\nnew file mode 100644\nindex 0000000..e856356\n--- /dev/null\n+++ b/t/t3507-cherry-pick-conflict.sh\n@@ -0,0 +1,198 @@\n+#!/bin/sh\n+\n+test_description='test cherry-pick and revert with conflicts\n+\n+  -\n+  + picked: rewrites foo to c\n+  + base: rewrites foo to b\n+  + initial: writes foo as a, unrelated as unrelated\n+\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\n+\techo unrelated >unrelated &&\n+\tgit add unrelated &&\n+\ttest_commit initial foo a &&\n+\ttest_commit base foo b &&\n+\ttest_commit picked foo c &&\n+\tgit config advice.detachedhead false\n+\n+'\n+\n+test_expect_success 'failed cherry-pick does not advance HEAD' '\n+\n+\tgit checkout -f initial^0 &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\thead=$(git rev-parse HEAD) &&\n+\ttest_must_fail git cherry-pick picked &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\n+\ttest \"$head\" = \"$newhead\"\n+'\n+\n+test_expect_success 'failed cherry-pick produces dirty index' '\n+\n+\tgit checkout -f initial^0 &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\ttest_must_fail git cherry-pick picked &&\n+\n+\ttest_must_fail git update-index --refresh -q &&\n+\ttest_must_fail git diff-index --exit-code HEAD\n+'\n+\n+test_expect_success 'failed cherry-pick registers participants in index' '\n+\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\t{\n+\t\tgit checkout base -- foo &&\n+\t\tgit ls-files --stage foo &&\n+\t\tgit checkout initial -- foo &&\n+\t\tgit ls-files --stage foo &&\n+\t\tgit checkout picked -- foo &&\n+\t\tgit ls-files --stage foo\n+\t} > stages &&\n+\tsed \"\n+\t\t1 s/ 0\t/ 1\t/\n+\t\t2 s/ 0\t/ 2\t/\n+\t\t3 s/ 0\t/ 3\t/\n+\t\" < stages > expected &&\n+\tgit checkout -f initial^0 &&\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\ttest_must_fail git cherry-pick picked &&\n+\tgit ls-files --stage --unmerged > actual &&\n+\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'failed cherry-pick describes conflict in work tree' '\n+\n+\tgit checkout -f initial^0 &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\tcat <<-EOF > expected &&\n+\t<<<<<<< HEAD\n+\ta\n+\t=======\n+\tc\n+\t>>>>>>> objid picked\n+\tEOF\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\ttest_must_fail git cherry-pick picked &&\n+\n+\tsed \"s/[a-f0-9]*\\.\\.\\./objid/\" foo > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'diff3 -m style' '\n+\n+\tgit config merge.conflictstyle diff3 &&\n+\tgit checkout -f initial^0 &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\tcat <<-EOF > expected &&\n+\t<<<<<<< HEAD\n+\ta\n+\t|||||||\n+\tb\n+\t=======\n+\tc\n+\t>>>>>>> objid picked\n+\tEOF\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\ttest_must_fail git cherry-pick picked &&\n+\n+\tsed \"s/[a-f0-9]*\\.\\.\\./objid/\" foo > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'revert also handles conflicts sanely' '\n+\n+\tgit config --unset merge.conflictstyle &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\tcat <<-EOF > expected &&\n+\t<<<<<<< HEAD\n+\ta\n+\t=======\n+\tb\n+\t>>>>>>> objid picked\n+\tEOF\n+\t{\n+\t\tgit checkout picked -- foo &&\n+\t\tgit ls-files --stage foo &&\n+\t\tgit checkout initial -- foo &&\n+\t\tgit ls-files --stage foo &&\n+\t\tgit checkout base -- foo &&\n+\t\tgit ls-files --stage foo\n+\t} > stages &&\n+\tsed \"\n+\t\t1 s/ 0\t/ 1\t/\n+\t\t2 s/ 0\t/ 2\t/\n+\t\t3 s/ 0\t/ 3\t/\n+\t\" < stages > expected-stages &&\n+\tgit checkout -f initial^0 &&\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\thead=$(git rev-parse HEAD) &&\n+\ttest_must_fail git revert picked &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tgit ls-files --stage --unmerged > actual-stages &&\n+\n+\ttest \"$head\" = \"$newhead\" &&\n+\ttest_must_fail git update-index --refresh -q &&\n+\ttest_must_fail git diff-index --exit-code HEAD &&\n+\ttest_cmp expected-stages actual-stages &&\n+\tsed \"s/[a-f0-9]*\\.\\.\\./objid/\" foo > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'revert conflict, diff3 -m style' '\n+\tgit config merge.conflictstyle diff3 &&\n+\tgit checkout -f initial^0 &&\n+\tgit read-tree -u --reset HEAD &&\n+\tgit clean -d -f -f -q -x &&\n+\tcat <<-EOF > expected &&\n+\t<<<<<<< HEAD\n+\ta\n+\t|||||||\n+\tc\n+\t=======\n+\tb\n+\t>>>>>>> objid picked\n+\tEOF\n+\n+\tgit update-index --refresh &&\n+\tgit diff-index --exit-code HEAD &&\n+\n+\ttest_must_fail git revert picked &&\n+\n+\tsed \"s/[a-f0-9]*\\.\\.\\./objid/\" foo > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_done\n-- \n1.7.0.2\n"},{"id":"137390","messageId":"20100321003144.GD23681@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 03/14] xdl_merge(): add optional ancestor label to diff3-style output","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:31:44Z","receivedAt":"2010-03-21T00:31:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The ‘git checkout --conflict=diff3’ command can be used to\npresent conflicts hunks including text from the common ancestor:\n\n\t<<<<<<< ours\n\tourside\n\t|||||||\n\toriginal\n\t=======\n\ttheirside\n\t>>>>>>> theirs\n\nThe added information is helpful for resolving merges by hand, and\nmerge tools can usually grok it because it is very similar to the\noutput from diff3 -m.\n\nA subtle change can help more tools to understand the output.  ‘diff3’\nincludes the name of the merge base on the ||||||| line of the output,\nand some tools misparse the conflict hunks without it.  Add a new\nxmp->ancestor parameter to xdl_merge() for use with conflict style\nXDL_MERGE_DIFF3 as a label on the ||||||| line for any conflict hunks.\n\nIf xmp->ancestor is NULL, the output format is unchanged.  Thus, this\nchange only provides unexposed plumbing for the new feature; it does\nnot affect the outward behavior of git.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nAcked-by: Bert Wesarg <Bert.Wesarg@googlemail.com>\n---\nSmall stylistic change:\n\n\tconst char *const ancestor_name = xmp->ancestor;\n\nas suggested in\n<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142393>.\n\n xdiff/xdiff.h  |    1 +\n xdiff/xmerge.c |   16 ++++++++++++++--\n 2 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/xdiff/xdiff.h b/xdiff/xdiff.h\nindex a71763a..6eb5fff 100644\n--- a/xdiff/xdiff.h\n+++ b/xdiff/xdiff.h\n@@ -117,6 +117,7 @@ typedef struct s_xmparam {\n \tint level;\n \tint favor;\n \tint style;\n+\tconst char *ancestor;\t/* label for orig */\n } xmparam_t;\n \n #define DEFAULT_CONFLICT_MARKER_SIZE 7\ndiff --git a/xdiff/xmerge.c b/xdiff/xmerge.c\nindex 87cafa7..9fc80ad 100644\n--- a/xdiff/xmerge.c\n+++ b/xdiff/xmerge.c\n@@ -145,11 +145,13 @@ static int xdl_orig_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest)\n \n static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,\n \t\t\t      xdfenv_t *xe2, const char *name2,\n+\t\t\t      const char *name3,\n \t\t\t      int size, int i, int style,\n \t\t\t      xdmerge_t *m, char *dest, int marker_size)\n {\n \tint marker1_size = (name1 ? strlen(name1) + 1 : 0);\n \tint marker2_size = (name2 ? strlen(name2) + 1 : 0);\n+\tint marker3_size = (name3 ? strlen(name3) + 1 : 0);\n \tint j;\n \n \tif (marker_size <= 0)\n@@ -179,10 +181,15 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,\n \tif (style == XDL_MERGE_DIFF3) {\n \t\t/* Shared preimage */\n \t\tif (!dest) {\n-\t\t\tsize += marker_size + 1;\n+\t\t\tsize += marker_size + 1 + marker3_size;\n \t\t} else {\n \t\t\tfor (j = 0; j < marker_size; j++)\n \t\t\t\tdest[size++] = '|';\n+\t\t\tif (marker3_size) {\n+\t\t\t\tdest[size] = ' ';\n+\t\t\t\tmemcpy(dest + size + 1, name3, marker3_size - 1);\n+\t\t\t\tsize += marker3_size;\n+\t\t\t}\n \t\t\tdest[size++] = '\\n';\n \t\t}\n \t\tsize += xdl_orig_copy(xe1, m->i0, m->chg0, 1,\n@@ -217,6 +224,7 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,\n \n static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,\n \t\t\t\t xdfenv_t *xe2, const char *name2,\n+\t\t\t\t const char *ancestor_name,\n \t\t\t\t int favor,\n \t\t\t\t xdmerge_t *m, char *dest, int style,\n \t\t\t\t int marker_size)\n@@ -229,6 +237,7 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,\n \n \t\tif (m->mode == 0)\n \t\t\tsize = fill_conflict_hunk(xe1, name1, xe2, name2,\n+\t\t\t\t\t\t  ancestor_name,\n \t\t\t\t\t\t  size, i, style, m, dest,\n \t\t\t\t\t\t  marker_size);\n \t\telse if (m->mode & 3) {\n@@ -403,6 +412,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,\n \t\txmparam_t const *xmp, mmbuffer_t *result) {\n \txdmerge_t *changes, *c;\n \txpparam_t const *xpp = &xmp->xpp;\n+\tconst char *const ancestor_name = xmp->ancestor;\n \tint i0, i1, i2, chg0, chg1, chg2;\n \tint level = xmp->level;\n \tint style = xmp->style;\n@@ -540,6 +550,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,\n \tif (result) {\n \t\tint marker_size = xmp->marker_size;\n \t\tint size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,\n+\t\t\t\t\t\t ancestor_name,\n \t\t\t\t\t\t favor, changes, NULL, style,\n \t\t\t\t\t\t marker_size);\n \t\tresult->ptr = xdl_malloc(size);\n@@ -548,7 +559,8 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,\n \t\t\treturn -1;\n \t\t}\n \t\tresult->size = size;\n-\t\txdl_fill_merge_buffer(xe1, name1, xe2, name2, favor, changes,\n+\t\txdl_fill_merge_buffer(xe1, name1, xe2, name2,\n+\t\t\t\t      ancestor_name, favor, changes,\n \t\t\t\t      result->ptr, style, marker_size);\n \t}\n \treturn xdl_cleanup_merge(changes);\n-- \n1.7.0.2\n"},{"id":"137391","messageId":"20100321003518.GE23681@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 04/14] xdl_merge(): move file1 and file2 labels to xmparam structure","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:35:18Z","receivedAt":"2010-03-21T00:35:18Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The labels for the three participants in a potential conflict are all\noptional arguments for the xdiff merge routine; if they are NULL, then\nxdl_merge() can cope by omitting the labels from its output.  Move\nthem to the xmparam structure to allow new callers to save some\nkeystrokes where they are not needed.\n\nThis also has the virtue of making the xdiff merge interface more\nsimilar to merge_trees, which might make it easier to learn.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nApplied saved resolution for conflict with commit 560119b (refactor merge\nflags into xmparam_t, 2010-03-01).  Thanks for writing rerere!\n\nPrevious version is at\n<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142377>.\n\n builtin/merge-file.c |    5 +++--\n ll-merge.c           |    4 +++-\n xdiff/xdiff.h        |    5 +++--\n xdiff/xmerge.c       |   19 +++++++++++--------\n 4 files changed, 20 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 69cc683..65eb790 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -77,8 +77,9 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\t\t\t\targv[i]);\n \t}\n \n-\tret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],\n-\t\t\t&xmp, &result);\n+\txmp.file1 = names[0];\n+\txmp.file2 = names[2];\n+\tret = xdl_merge(mmfs + 1, mmfs + 0, mmfs + 2, &xmp, &result);\n \n \tfor (i = 0; i < 3; i++)\n \t\tfree(mmfs[i].ptr);\ndiff --git a/ll-merge.c b/ll-merge.c\nindex 82c7742..184948d 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -83,7 +83,9 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n \t\txmp.style = git_xmerge_style;\n \tif (marker_size > 0)\n \t\txmp.marker_size = marker_size;\n-\treturn xdl_merge(orig, src1, name1, src2, name2, &xmp, result);\n+\txmp.file1 = name1;\n+\txmp.file2 = name2;\n+\treturn xdl_merge(orig, src1, src2, &xmp, result);\n }\n \n static int ll_union_merge(const struct ll_merge_driver *drv_unused,\ndiff --git a/xdiff/xdiff.h b/xdiff/xdiff.h\nindex 6eb5fff..711048e 100644\n--- a/xdiff/xdiff.h\n+++ b/xdiff/xdiff.h\n@@ -118,12 +118,13 @@ typedef struct s_xmparam {\n \tint favor;\n \tint style;\n \tconst char *ancestor;\t/* label for orig */\n+\tconst char *file1;\t/* label for mf1 */\n+\tconst char *file2;\t/* label for mf2 */\n } xmparam_t;\n \n #define DEFAULT_CONFLICT_MARKER_SIZE 7\n \n-int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,\n-\t\tmmfile_t *mf2, const char *name2,\n+int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,\n \t\txmparam_t const *xmp, mmbuffer_t *result);\n \n #ifdef __cplusplus\ndiff --git a/xdiff/xmerge.c b/xdiff/xmerge.c\nindex 9fc80ad..16dd9ac 100644\n--- a/xdiff/xmerge.c\n+++ b/xdiff/xmerge.c\n@@ -407,12 +407,15 @@ static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m,\n  *\n  * returns < 0 on error, == 0 for no conflicts, else number of conflicts\n  */\n-static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,\n-\t\txdfenv_t *xe2, xdchange_t *xscr2, const char *name2,\n-\t\txmparam_t const *xmp, mmbuffer_t *result) {\n+static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,\n+\t\txdfenv_t *xe2, xdchange_t *xscr2,\n+\t\txmparam_t const *xmp, mmbuffer_t *result)\n+{\n \txdmerge_t *changes, *c;\n \txpparam_t const *xpp = &xmp->xpp;\n \tconst char *const ancestor_name = xmp->ancestor;\n+\tconst char *const name1 = xmp->file1;\n+\tconst char *const name2 = xmp->file2;\n \tint i0, i1, i2, chg0, chg1, chg2;\n \tint level = xmp->level;\n \tint style = xmp->style;\n@@ -566,9 +569,9 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,\n \treturn xdl_cleanup_merge(changes);\n }\n \n-int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,\n-\t\tmmfile_t *mf2, const char *name2,\n-\t\txmparam_t const *xmp, mmbuffer_t *result) {\n+int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,\n+\t\txmparam_t const *xmp, mmbuffer_t *result)\n+{\n \txdchange_t *xscr1, *xscr2;\n \txdfenv_t xe1, xe2;\n \tint status;\n@@ -603,8 +606,8 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,\n \t\tmemcpy(result->ptr, mf1->ptr, mf1->size);\n \t\tresult->size = mf1->size;\n \t} else {\n-\t\tstatus = xdl_do_merge(&xe1, xscr1, name1,\n-\t\t\t\t      &xe2, xscr2, name2,\n+\t\tstatus = xdl_do_merge(&xe1, xscr1,\n+\t\t\t\t      &xe2, xscr2,\n \t\t\t\t      xmp, result);\n \t}\n \txdl_free_script(xscr1);\n-- \n1.7.0.2\n"},{"id":"137392","messageId":"20100321003733.GF23681@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 05/14] merge-file --diff3: add a label for ancestor","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:37:33Z","receivedAt":"2010-03-21T00:37:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"git merge-file --diff3 can be used to present conflicts hunks\nincluding text from the common ancestor.\n\nThe added information is helpful for resolving a merge by hand, and\nmerge tools can usually grok it because it looks like output from\ndiff3 -m.  However, ‘diff3’ includes a label for the merge base on the\n||||||| line and some tools cannot parse conflict hunks without such a\nlabel.  Write the base-name as passed in a -L option (or the name of\nthe ancestor file by default) on that line.\n\ngit rerere will not have trouble parsing this output, since instead of\nlooking for a newline, it looks for whitespace after the |||||||\nmarker.  Since rerere includes its own code for recreating conflict\nhunks, conflict identifiers are unaffected.  No other code in git tries\nto parse conflict hunks.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nAdapts test for 11f3aa23 (merge-file: add option to specify the marker\nsize, 2010-03-01) as described at\n<http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142378>.\n\n builtin/merge-file.c  |    1 +\n t/t6023-merge-file.sh |    4 ++--\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 65eb790..610849a 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -77,6 +77,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\t\t\t\targv[i]);\n \t}\n \n+\txmp.ancestor = names[1];\n \txmp.file1 = names[0];\n \txmp.file2 = names[2];\n \tret = xdl_merge(mmfs + 1, mmfs + 0, mmfs + 2, &xmp, &result);\ndiff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh\nindex 5034dd1..d486d73 100755\n--- a/t/t6023-merge-file.sh\n+++ b/t/t6023-merge-file.sh\n@@ -181,7 +181,7 @@ et nihil mihi deerit;\n \n In loco pascuae ibi me collocavit;\n super aquam refectionis educavit me.\n-|||||||\n+||||||| new5.txt\n et nihil mihi deerit.\n In loco pascuae ibi me collocavit,\n super aquam refectionis educavit me;\n@@ -225,7 +225,7 @@ et nihil mihi deerit;\n \n In loco pascuae ibi me collocavit;\n super aquam refectionis educavit me.\n-||||||||||\n+|||||||||| new5.txt\n et nihil mihi deerit.\n In loco pascuae ibi me collocavit,\n super aquam refectionis educavit me;\n-- \n1.7.0.2\n"},{"id":"137393","messageId":"20100321003857.GA23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 06/14] ll_merge(): add ancestor label parameter for diff3-style output","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:38:58Z","receivedAt":"2010-03-21T00:38:58Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Commands using the ll_merge() function will present conflict hunks\nimitating ‘diff3 -m’ output if the merge.conflictstyle configuration\noption is set appropriately.  Unlike ‘diff3 -m’, the output does not\ninclude a label for the merge base on the ||||||| line of the output,\nand some tools misparse the conflict hunks without that.\n\nAdd a new ancestor_label parameter to ll_merge() to give callers the\npower to rectify this situation.  If ancestor_label is NULL, the output\nformat is unchanged.  All callers pass NULL for now.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142379>.\n\n builtin/checkout.c |    2 +-\n ll-merge.c         |   20 +++++++++++---------\n ll-merge.h         |    2 +-\n merge-file.c       |    2 +-\n merge-recursive.c  |    2 +-\n rerere.c           |    4 ++--\n 6 files changed, 17 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex acefaaf..d67f809 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state)\n \tread_mmblob(&ours, active_cache[pos+1]->sha1);\n \tread_mmblob(&theirs, active_cache[pos+2]->sha1);\n \n-\tstatus = ll_merge(&result_buf, path, &ancestor,\n+\tstatus = ll_merge(&result_buf, path, &ancestor, NULL,\n \t\t\t  &ours, \"ours\", &theirs, \"theirs\", 0);\n \tfree(ancestor.ptr);\n \tfree(ours.ptr);\ndiff --git a/ll-merge.c b/ll-merge.c\nindex 184948d..f9b3d85 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -15,7 +15,7 @@ struct ll_merge_driver;\n typedef int (*ll_merge_fn)(const struct ll_merge_driver *,\n \t\t\t   mmbuffer_t *result,\n \t\t\t   const char *path,\n-\t\t\t   mmfile_t *orig,\n+\t\t\t   mmfile_t *orig, const char *orig_name,\n \t\t\t   mmfile_t *src1, const char *name1,\n \t\t\t   mmfile_t *src2, const char *name2,\n \t\t\t   int flag,\n@@ -36,7 +36,7 @@ struct ll_merge_driver {\n static int ll_binary_merge(const struct ll_merge_driver *drv_unused,\n \t\t\t   mmbuffer_t *result,\n \t\t\t   const char *path_unused,\n-\t\t\t   mmfile_t *orig,\n+\t\t\t   mmfile_t *orig, const char *orig_name,\n \t\t\t   mmfile_t *src1, const char *name1,\n \t\t\t   mmfile_t *src2, const char *name2,\n \t\t\t   int flag, int marker_size)\n@@ -57,7 +57,7 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,\n static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n \t\t\tmmbuffer_t *result,\n \t\t\tconst char *path,\n-\t\t\tmmfile_t *orig,\n+\t\t\tmmfile_t *orig, const char *orig_name,\n \t\t\tmmfile_t *src1, const char *name1,\n \t\t\tmmfile_t *src2, const char *name2,\n \t\t\tint flag, int marker_size)\n@@ -71,7 +71,8 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n \t\t\tpath, name1, name2);\n \t\treturn ll_binary_merge(drv_unused, result,\n \t\t\t\t       path,\n-\t\t\t\t       orig, src1, name1,\n+\t\t\t\t       orig, orig_name,\n+\t\t\t\t       src1, name1,\n \t\t\t\t       src2, name2,\n \t\t\t\t       flag, marker_size);\n \t}\n@@ -83,6 +84,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n \t\txmp.style = git_xmerge_style;\n \tif (marker_size > 0)\n \t\txmp.marker_size = marker_size;\n+\txmp.ancestor = orig_name;\n \txmp.file1 = name1;\n \txmp.file2 = name2;\n \treturn xdl_merge(orig, src1, src2, &xmp, result);\n@@ -91,7 +93,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n static int ll_union_merge(const struct ll_merge_driver *drv_unused,\n \t\t\t  mmbuffer_t *result,\n \t\t\t  const char *path_unused,\n-\t\t\t  mmfile_t *orig,\n+\t\t\t  mmfile_t *orig, const char *orig_name,\n \t\t\t  mmfile_t *src1, const char *name1,\n \t\t\t  mmfile_t *src2, const char *name2,\n \t\t\t  int flag, int marker_size)\n@@ -99,7 +101,7 @@ static int ll_union_merge(const struct ll_merge_driver *drv_unused,\n \t/* Use union favor */\n \tflag = (flag & 1) | (XDL_MERGE_FAVOR_UNION << 1);\n \treturn ll_xdl_merge(drv_unused, result, path_unused,\n-\t\t\t    orig, src1, NULL, src2, NULL,\n+\t\t\t    orig, NULL, src1, NULL, src2, NULL,\n \t\t\t    flag, marker_size);\n \treturn 0;\n }\n@@ -130,7 +132,7 @@ static void create_temp(mmfile_t *src, char *path)\n static int ll_ext_merge(const struct ll_merge_driver *fn,\n \t\t\tmmbuffer_t *result,\n \t\t\tconst char *path,\n-\t\t\tmmfile_t *orig,\n+\t\t\tmmfile_t *orig, const char *orig_name,\n \t\t\tmmfile_t *src1, const char *name1,\n \t\t\tmmfile_t *src2, const char *name2,\n \t\t\tint flag, int marker_size)\n@@ -321,7 +323,7 @@ static int git_path_check_merge(const char *path, struct git_attr_check check[2]\n \n int ll_merge(mmbuffer_t *result_buf,\n \t     const char *path,\n-\t     mmfile_t *ancestor,\n+\t     mmfile_t *ancestor, const char *ancestor_label,\n \t     mmfile_t *ours, const char *our_label,\n \t     mmfile_t *theirs, const char *their_label,\n \t     int flag)\n@@ -343,7 +345,7 @@ int ll_merge(mmbuffer_t *result_buf,\n \tdriver = find_ll_merge_driver(ll_driver_name);\n \tif (virtual_ancestor && driver->recursive)\n \t\tdriver = find_ll_merge_driver(driver->recursive);\n-\treturn driver->fn(driver, result_buf, path, ancestor,\n+\treturn driver->fn(driver, result_buf, path, ancestor, ancestor_label,\n \t\t\t  ours, our_label, theirs, their_label,\n \t\t\t  flag, marker_size);\n }\ndiff --git a/ll-merge.h b/ll-merge.h\nindex 5788922..57754cc 100644\n--- a/ll-merge.h\n+++ b/ll-merge.h\n@@ -7,7 +7,7 @@\n \n int ll_merge(mmbuffer_t *result_buf,\n \t     const char *path,\n-\t     mmfile_t *ancestor,\n+\t     mmfile_t *ancestor, const char *ancestor_label,\n \t     mmfile_t *ours, const char *our_label,\n \t     mmfile_t *theirs, const char *their_label,\n \t     int flag);\ndiff --git a/merge-file.c b/merge-file.c\nindex fd34d76..07cc0c9 100644\n--- a/merge-file.c\n+++ b/merge-file.c\n@@ -30,7 +30,7 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our\n \tint merge_status;\n \tmmbuffer_t res;\n \n-\tmerge_status = ll_merge(&res, path, base,\n+\tmerge_status = ll_merge(&res, path, base, NULL,\n \t\t\t\tour, \".our\", their, \".their\", 0);\n \tif (merge_status < 0)\n \t\treturn NULL;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 195ebf9..3b2cc9d 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -640,7 +640,7 @@ static int merge_3way(struct merge_options *o,\n \tread_mmblob(&src1, a->sha1);\n \tread_mmblob(&src2, b->sha1);\n \n-\tmerge_status = ll_merge(result_buf, a->path, &orig,\n+\tmerge_status = ll_merge(result_buf, a->path, &orig, NULL,\n \t\t\t\t&src1, name1, &src2, name2,\n \t\t\t\t(!!o->call_depth) | (favor << 1));\n \ndiff --git a/rerere.c b/rerere.c\nindex a59f74f..f221bed 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -319,7 +319,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \t\tif (!mmfile[i].ptr && !mmfile[i].size)\n \t\t\tmmfile[i].ptr = xstrdup(\"\");\n \t}\n-\tll_merge(&result, path, &mmfile[0],\n+\tll_merge(&result, path, &mmfile[0], NULL,\n \t\t &mmfile[1], \"ours\",\n \t\t &mmfile[2], \"theirs\", 0);\n \tfor (i = 0; i < 3; i++)\n@@ -376,7 +376,7 @@ static int merge(const char *name, const char *path)\n \t\tret = 1;\n \t\tgoto out;\n \t}\n-\tret = ll_merge(&result, path, &base, &cur, \"\", &other, \"\", 0);\n+\tret = ll_merge(&result, path, &base, NULL, &cur, \"\", &other, \"\", 0);\n \tif (!ret) {\n \t\tFILE *f = fopen(path, \"w\");\n \t\tif (!f)\n-- \n1.7.0.2\n"},{"id":"137394","messageId":"20100321004019.GB23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 07/14] checkout --conflict=diff3: add a label for ancestor","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:40:19Z","receivedAt":"2010-03-21T00:40:19Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"git checkout --conflict=diff3 can be used to present conflicts hunks\nincluding text from the common ancestor:\n\n\t<<<<<<< ours\n\tourside\n\t|||||||\n\toriginal\n\t=======\n\ttheirside\n\t>>>>>>> theirs\n\nThe added information is helpful for resolving a merge by hand, and\nmerge tools can usually understand it without trouble because it looks\nlike output from ‘diff3 -m’.\n\ndiff3 includes a label for the merge base on the ||||||| line, and it\nseems some tools (for example, Emacs 22’s smerge-mode) cannot parse\nconflict hunks without such a label.  Humans could use help in\ninterpreting the output, too.  So change the marker for the start of the\ntext from the common ancestor to include the label “base”.\n\ngit rerere’s conflict identifiers are not affected: to parse conflict\nhunks, rerere looks for whitespace after the ||||||| marker rather\nthan a newline, and to compute preimage ids, rerere has its own code\nfor creating conflict hunks.  No other code in git tries to parse\nconflict hunks.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142380>.\n\n builtin/checkout.c |    2 +-\n t/t7201-co.sh      |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d67f809..d652b4c 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state)\n \tread_mmblob(&ours, active_cache[pos+1]->sha1);\n \tread_mmblob(&theirs, active_cache[pos+2]->sha1);\n \n-\tstatus = ll_merge(&result_buf, path, &ancestor, NULL,\n+\tstatus = ll_merge(&result_buf, path, &ancestor, \"base\",\n \t\t\t  &ours, \"ours\", &theirs, \"theirs\", 0);\n \tfree(ancestor.ptr);\n \tfree(ours.ptr);\ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex 01175f7..f3f0c4c 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -538,7 +538,7 @@ test_expect_success 'checkout with --merge, in diff3 -m style' '\n \t(\n \t\techo \"<<<<<<< ours\"\n \t\techo ourside\n-\t\techo \"|||||||\"\n+\t\techo \"||||||| base\"\n \t\techo original\n \t\techo \"=======\"\n \t\techo theirside\n@@ -582,7 +582,7 @@ test_expect_success 'checkout --conflict=diff3' '\n \t(\n \t\techo \"<<<<<<< ours\"\n \t\techo ourside\n-\t\techo \"|||||||\"\n+\t\techo \"||||||| base\"\n \t\techo original\n \t\techo \"=======\"\n \t\techo theirside\n-- \n1.7.0.2\n"},{"id":"137395","messageId":"20100321004053.GC23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 08/14] merge_file(): add comment explaining behavior wrt conflict style","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:40:53Z","receivedAt":"2010-03-21T00:40:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The merge_file() function is a helper for ‘git read-tree’, which does\nnot respect the merge.conflictstyle option, so there is no need to\nworry about what ancestor_name it should pass to ll_merge().  Add a\ncomment to this effect.\n\nSigned-off-by: Jonathan Nieder <jrnieder@mgila.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142381>.\n\n merge-file.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/merge-file.c b/merge-file.c\nindex 07cc0c9..c336c93 100644\n--- a/merge-file.c\n+++ b/merge-file.c\n@@ -30,6 +30,12 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our\n \tint merge_status;\n \tmmbuffer_t res;\n \n+\t/*\n+\t * This function is only used by cmd_merge_tree, which\n+\t * does not respect the merge.conflictstyle option.\n+\t * There is no need to worry about a label for the\n+\t * common ancestor.\n+\t */\n \tmerge_status = ll_merge(&res, path, base, NULL,\n \t\t\t\tour, \".our\", their, \".their\", 0);\n \tif (merge_status < 0)\n-- \n1.7.0.2\n"},{"id":"137396","messageId":"20100321004138.GD23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 09/14] merge_trees(): add ancestor label parameter for diff3-style output","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:41:38Z","receivedAt":"2010-03-21T00:41:38Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Commands using the merge_trees() machinery will present conflict hunks\nin output something like what ‘diff3 -m’ produces if the\nmerge.conflictstyle configuration option is set to diff3.  The output\nlacks the name of the merge base on the ||||||| line of the output,\nand tools can misparse the conflict hunks without it.  Add a new\no->ancestor parameter to merge_trees() for use as a label for the\nancestor in conflict hunks.\n\nIf o->ancestor is NULL, the output format is as before.  All callers\npass NULL for now.\n\nIf o->ancestor is non-NULL and both branches renamed the base file\nto the same name, that name is included in the conflict hunk labels.\nEven if o->ancestor is NULL I think this would be a good change, but\nthis patch only does it in the non-NULL case to ensure the output\nformat does not change where it might matter.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142382>.\n\n merge-recursive.c |   11 ++++++++---\n merge-recursive.h |    1 +\n 2 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 3b2cc9d..017cafd 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -608,7 +608,7 @@ static int merge_3way(struct merge_options *o,\n \t\t      const char *branch2)\n {\n \tmmfile_t orig, src1, src2;\n-\tchar *name1, *name2;\n+\tchar *base_name, *name1, *name2;\n \tint merge_status;\n \tint favor;\n \n@@ -628,10 +628,15 @@ static int merge_3way(struct merge_options *o,\n \t\t}\n \t}\n \n-\tif (strcmp(a->path, b->path)) {\n+\tif (strcmp(a->path, b->path) ||\n+\t    (o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {\n+\t\tbase_name = o->ancestor == NULL ? NULL :\n+\t\t\txstrdup(mkpath(\"%s:%s\", o->ancestor, one->path));\n \t\tname1 = xstrdup(mkpath(\"%s:%s\", branch1, a->path));\n \t\tname2 = xstrdup(mkpath(\"%s:%s\", branch2, b->path));\n \t} else {\n+\t\tbase_name = o->ancestor == NULL ? NULL :\n+\t\t\txstrdup(mkpath(\"%s\", o->ancestor));\n \t\tname1 = xstrdup(mkpath(\"%s\", branch1));\n \t\tname2 = xstrdup(mkpath(\"%s\", branch2));\n \t}\n@@ -640,7 +645,7 @@ static int merge_3way(struct merge_options *o,\n \tread_mmblob(&src1, a->sha1);\n \tread_mmblob(&src2, b->sha1);\n \n-\tmerge_status = ll_merge(result_buf, a->path, &orig, NULL,\n+\tmerge_status = ll_merge(result_buf, a->path, &orig, base_name,\n \t\t\t\t&src1, name1, &src2, name2,\n \t\t\t\t(!!o->call_depth) | (favor << 1));\n \ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex be8410a..d1192f5 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -4,6 +4,7 @@\n #include \"string-list.h\"\n \n struct merge_options {\n+\tconst char *ancestor;\n \tconst char *branch1;\n \tconst char *branch2;\n \tenum {\n-- \n1.7.0.2\n"},{"id":"137397","messageId":"20100321004251.GE23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 10/14] checkout -m --conflict=diff3: add a label for ancestor","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:42:51Z","receivedAt":"2010-03-21T00:42:51Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"git checkout --merge --conflict=diff3 can be used to present conflict\nhunks including text from the common ancestor.  The added information\nis helpful for resolving a merge by hand, and merge tools tend to\nunderstand it because it is very similar to what ‘diff3 -m’ produces.\n\nUnlike current git, diff3 -m includes a label for the merge base on\nthe ||||||| line, and unfortunately, some tools cannot parse the\nconflict hunks without it.  Humans can benefit from a cue when\nlearning to interpreting the format, too.  Mark the start of the text\nfrom the old branch with a label based on the branch’s name.\n\ngit rerere does not have trouble parsing this output and its preimage\nids are unchanged since it includes its own code for recreating\nconflict hunks.  No other code in git tries to parse conflict hunks.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142384>.\n\n builtin/checkout.c |    1 +\n t/t7201-co.sh      |    2 +-\n 2 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex d652b4c..88b1f43 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -439,6 +439,7 @@ static int merge_working_tree(struct checkout_opts *opts,\n \t\t\tret = reset_tree(new->commit->tree, opts, 1);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n+\t\t\to.ancestor = old->name;\n \t\t\to.branch1 = new->name;\n \t\t\to.branch2 = \"local\";\n \t\t\tmerge_trees(&o, new->commit->tree, work,\ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex f3f0c4c..1337fa5 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -209,7 +209,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '\n \ta\n \tc\n \te\n-\t|||||||\n+\t||||||| master\n \ta\n \tb\n \tc\n-- \n1.7.0.2\n"},{"id":"137398","messageId":"20100321004332.GF23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 11/14] compat: add mempcpy()","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:43:32Z","receivedAt":"2010-03-21T00:43:32Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The mempcpy() function was added in glibc 2.1.  It is quite handy, so\nadd an implementation for cross-platform use.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142387>.\n\n git-compat-util.h |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex a3c4537..9bed5a0 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -331,6 +331,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,\n #ifdef __GLIBC_PREREQ\n #if __GLIBC_PREREQ(2, 1)\n #define HAVE_STRCHRNUL\n+#define HAVE_MEMPCPY\n #endif\n #endif\n \n@@ -344,6 +345,14 @@ static inline char *gitstrchrnul(const char *s, int c)\n }\n #endif\n \n+#ifndef HAVE_MEMPCPY\n+#define mempcpy gitmempcpy\n+static inline void *gitmempcpy(void *dest, const void *src, size_t n)\n+{\n+\treturn (char *)memcpy(dest, src, n) + n;\n+}\n+#endif\n+\n extern void release_pack_memory(size_t, int);\n \n extern char *xstrdup(const char *str);\n-- \n1.7.0.2\n"},{"id":"137399","messageId":"20100321004521.GG23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 12/14] revert: clarify label on conflict hunks","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:45:21Z","receivedAt":"2010-03-21T00:45:21Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"When reverting a commit, the commit being merged is not the commit\nto revert itself but its parent.  Add “parent of” to the conflict\nhunk label to make this more clear.\n\nThe conflict hunk labels are all pieces of a single string written in\nthe new get_message() function.  Avoid some complication by using\nmempcpy to advance a pointer as the result is written.\n\nAlso free the corresponding temporary buffer (it was leaked before).\nThis is not important because it is a small one-time allocation.  It\nwould become a memory leak if unnoticed when libifying revert.\n\nThis patch uses calls to strlen() instead of integer constants in some\nplaces.  GCC will compute the length at compile time; I am not sure\nabout other compilers, but this is not performance-critical anyway.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142448>.\n\nThanks to Stephen for advice.\n\n builtin/revert.c                |  100 ++++++++++++++++++++++++---------------\n t/t3507-cherry-pick-conflict.sh |    4 +-\n 2 files changed, 63 insertions(+), 41 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex eff5268..b314629 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -45,6 +45,8 @@ static const char *me;\n \n #define GIT_REFLOG_ACTION \"GIT_REFLOG_ACTION\"\n \n+static char *get_encoding(const char *message);\n+\n static void parse_args(int argc, const char **argv)\n {\n \tconst char * const * usage_str =\n@@ -73,33 +75,63 @@ static void parse_args(int argc, const char **argv)\n \t\texit(1);\n }\n \n-static char *get_oneline(const char *message)\n+struct commit_message {\n+\tchar *parent_label;\n+\tconst char *label;\n+\tconst char *subject;\n+\tchar *reencoded_message;\n+\tconst char *message;\n+};\n+\n+static int get_message(const char *raw_message, struct commit_message *out)\n {\n-\tchar *result;\n-\tconst char *p = message, *abbrev, *eol;\n+\tconst char *encoding;\n+\tconst char *p, *abbrev, *eol;\n+\tchar *q;\n \tint abbrev_len, oneline_len;\n \n-\tif (!p)\n-\t\tdie (\"Could not read commit message of %s\",\n-\t\t\t\tsha1_to_hex(commit->object.sha1));\n+\tif (!raw_message)\n+\t\treturn -1;\n+\tencoding = get_encoding(raw_message);\n+\tif (!encoding)\n+\t\tencoding = \"UTF-8\";\n+\tif (!git_commit_encoding)\n+\t\tgit_commit_encoding = \"UTF-8\";\n+\tif ((out->reencoded_message = reencode_string(raw_message,\n+\t\t\t\t\tgit_commit_encoding, encoding)))\n+\t\tout->message = out->reencoded_message;\n+\n+\tabbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);\n+\tabbrev_len = strlen(abbrev);\n+\n+\t/* Find beginning and end of commit subject. */\n+\tp = out->message;\n \twhile (*p && (*p != '\\n' || p[1] != '\\n'))\n \t\tp++;\n-\n \tif (*p) {\n \t\tp += 2;\n \t\tfor (eol = p + 1; *eol && *eol != '\\n'; eol++)\n \t\t\t; /* do nothing */\n \t} else\n \t\teol = p;\n-\tabbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);\n-\tabbrev_len = strlen(abbrev);\n \toneline_len = eol - p;\n-\tresult = xmalloc(abbrev_len + 5 + oneline_len);\n-\tmemcpy(result, abbrev, abbrev_len);\n-\tmemcpy(result + abbrev_len, \"... \", 4);\n-\tmemcpy(result + abbrev_len + 4, p, oneline_len);\n-\tresult[abbrev_len + 4 + oneline_len] = '\\0';\n-\treturn result;\n+\n+\tout->parent_label = xmalloc(strlen(\"parent of \") + abbrev_len +\n+\t\t\t      strlen(\"... \") + oneline_len + 1);\n+\tq = out->parent_label;\n+\tq = mempcpy(q, \"parent of \", strlen(\"parent of \"));\n+\tout->label = q;\n+\tq = mempcpy(q, abbrev, abbrev_len);\n+\tq = mempcpy(q, \"... \", strlen(\"... \"));\n+\tout->subject = q;\n+\tq = mempcpy(q, p, oneline_len);\n+\t*q = '\\0';\n+\treturn 0;\n+}\n+\n+static void free_message(struct commit_message *msg) {\n+\tfree(msg->parent_label);\n+\tfree(msg->reencoded_message);\n }\n \n static char *get_encoding(const char *message)\n@@ -248,9 +280,10 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n {\n \tunsigned char head[20];\n \tstruct commit *base, *next, *parent;\n+\tconst char *next_label;\n \tint i, index_fd, clean;\n-\tchar *oneline, *reencoded_message = NULL;\n-\tconst char *message, *encoding;\n+\tstruct commit_message msg = { NULL, NULL, NULL, NULL, NULL };\n+\n \tchar *defmsg = git_pathdup(\"MERGE_MSG\");\n \tstruct merge_options o;\n \tstruct tree *result, *next_tree, *base_tree, *head_tree;\n@@ -314,14 +347,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \telse\n \t\tparent = commit->parents->item;\n \n-\tif (!(message = commit->buffer))\n-\t\tdie (\"Cannot get commit message for %s\",\n-\t\t\t\tsha1_to_hex(commit->object.sha1));\n-\n \tif (parent && parse_commit(parent) < 0)\n \t\tdie(\"%s: cannot parse parent commit %s\",\n \t\t    me, sha1_to_hex(parent->object.sha1));\n \n+\tif (get_message(commit->buffer, &msg) != 0)\n+\t\tdie (\"Cannot get commit message for %s\",\n+\t\t\t\tsha1_to_hex(commit->object.sha1));\n+\n \t/*\n \t * \"commit\" is an existing commit.  We would want to apply\n \t * the difference it introduces since its first parent \"prev\"\n@@ -332,24 +365,12 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \tmsg_fd = hold_lock_file_for_update(&msg_file, defmsg,\n \t\t\t\t\t   LOCK_DIE_ON_ERROR);\n \n-\tencoding = get_encoding(message);\n-\tif (!encoding)\n-\t\tencoding = \"UTF-8\";\n-\tif (!git_commit_encoding)\n-\t\tgit_commit_encoding = \"UTF-8\";\n-\tif ((reencoded_message = reencode_string(message,\n-\t\t\t\t\tgit_commit_encoding, encoding)))\n-\t\tmessage = reencoded_message;\n-\n-\toneline = get_oneline(message);\n-\n \tif (action == REVERT) {\n-\t\tchar *oneline_body = strchr(oneline, ' ');\n-\n \t\tbase = commit;\n \t\tnext = parent;\n+\t\tnext_label = msg.parent_label;\n \t\tadd_to_msg(\"Revert \\\"\");\n-\t\tadd_to_msg(oneline_body + 1);\n+\t\tadd_to_msg(msg.subject);\n \t\tadd_to_msg(\"\\\"\\n\\nThis reverts commit \");\n \t\tadd_to_msg(sha1_to_hex(commit->object.sha1));\n \n@@ -361,8 +382,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t} else {\n \t\tbase = parent;\n \t\tnext = commit;\n-\t\tset_author_ident_env(message);\n-\t\tadd_message_to_msg(message);\n+\t\tnext_label = msg.label;\n+\t\tset_author_ident_env(msg.message);\n+\t\tadd_message_to_msg(msg.message);\n \t\tif (no_replay) {\n \t\t\tadd_to_msg(\"(cherry picked from commit \");\n \t\t\tadd_to_msg(sha1_to_hex(commit->object.sha1));\n@@ -373,7 +395,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \tread_cache();\n \tinit_merge_options(&o);\n \to.branch1 = \"HEAD\";\n-\to.branch2 = oneline;\n+\to.branch2 = next ? next_label : \"(empty tree)\";\n \n \thead_tree = parse_tree_indirect(head);\n \tnext_tree = next ? next->tree : empty_tree();\n@@ -437,7 +459,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\targs[i] = NULL;\n \t\treturn execv_git_cmd(args);\n \t}\n-\tfree(reencoded_message);\n+\tfree_message(&msg);\n \tfree(defmsg);\n \n \treturn 0;\ndiff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh\nindex e856356..6a20817 100644\n--- a/t/t3507-cherry-pick-conflict.sh\n+++ b/t/t3507-cherry-pick-conflict.sh\n@@ -138,7 +138,7 @@ test_expect_success 'revert also handles conflicts sanely' '\n \ta\n \t=======\n \tb\n-\t>>>>>>> objid picked\n+\t>>>>>>> parent of objid picked\n \tEOF\n \t{\n \t\tgit checkout picked -- foo &&\n@@ -183,7 +183,7 @@ test_expect_success 'revert conflict, diff3 -m style' '\n \tc\n \t=======\n \tb\n-\t>>>>>>> objid picked\n+\t>>>>>>> parent of objid picked\n \tEOF\n \n \tgit update-index --refresh &&\n-- \n1.7.0.2\n"},{"id":"137400","messageId":"20100321004607.GH23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 13/14] cherry-pick, revert: add a label for ancestor","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:46:07Z","receivedAt":"2010-03-21T00:46:07Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"When writing conflict hunks in ‘diff3 -m’ format, also add a label to\nthe common ancestor.  Especially in a cherry-pick, it is not immediately\nobvious without such a label what the common ancestor represents.\n\ngit rerere does not have trouble parsing the new output and its preimage\nids are unchanged since it includes its own code for recreating conflict\nhunks.  No other code in git parses conflict hunks.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142449>.\n\n builtin/revert.c                |    5 ++++-\n t/t3507-cherry-pick-conflict.sh |    4 ++--\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex b314629..625281c 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -280,7 +280,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n {\n \tunsigned char head[20];\n \tstruct commit *base, *next, *parent;\n-\tconst char *next_label;\n+\tconst char *base_label, *next_label;\n \tint i, index_fd, clean;\n \tstruct commit_message msg = { NULL, NULL, NULL, NULL, NULL };\n \n@@ -367,6 +367,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \n \tif (action == REVERT) {\n \t\tbase = commit;\n+\t\tbase_label = msg.label;\n \t\tnext = parent;\n \t\tnext_label = msg.parent_label;\n \t\tadd_to_msg(\"Revert \\\"\");\n@@ -381,6 +382,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \t\tadd_to_msg(\".\\n\");\n \t} else {\n \t\tbase = parent;\n+\t\tbase_label = msg.parent_label;\n \t\tnext = commit;\n \t\tnext_label = msg.label;\n \t\tset_author_ident_env(msg.message);\n@@ -394,6 +396,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)\n \n \tread_cache();\n \tinit_merge_options(&o);\n+\to.ancestor = base ? base_label : \"(empty tree)\";\n \to.branch1 = \"HEAD\";\n \to.branch2 = next ? next_label : \"(empty tree)\";\n \ndiff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh\nindex 6a20817..e25cf80 100644\n--- a/t/t3507-cherry-pick-conflict.sh\n+++ b/t/t3507-cherry-pick-conflict.sh\n@@ -112,7 +112,7 @@ test_expect_success 'diff3 -m style' '\n \tcat <<-EOF > expected &&\n \t<<<<<<< HEAD\n \ta\n-\t|||||||\n+\t||||||| parent of objid picked\n \tb\n \t=======\n \tc\n@@ -179,7 +179,7 @@ test_expect_success 'revert conflict, diff3 -m style' '\n \tcat <<-EOF > expected &&\n \t<<<<<<< HEAD\n \ta\n-\t|||||||\n+\t||||||| objid picked\n \tc\n \t=======\n \tb\n-- \n1.7.0.2\n"},{"id":"137401","messageId":"20100321005221.GI23888@progeny.tock","threadId":"23113","inReplyTo":"20100321002535.GA23681@progeny.tock","subject":"[PATCH 14/14] merge-recursive: add a label for ancestor","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-03-21T00:52:21Z","receivedAt":"2010-03-21T00:52:21Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"git merge-recursive (and hence git merge) will present conflict hunks\nin output something like what ‘diff3 -m’ produces if the\nmerge.conflictstyle configuration option is set to diff3.\nThere is a small difference from diff3: diff3 -m includes a label\nfor the merge base on the ||||||| line.\n\nTools familiar with the format and humans unfamiliar with the format\nboth can benefit from such a label.  So mark the start of the text\nfrom the merge bases with the heading \"||||||| merged common\nancestors\".\n\nIt would be nicer to use a more informative label.  Perhaps someone\nwill provide one some day.\n\ngit rerere does not have trouble parsing the new output, and its\npreimage ids are unchanged since it has its own code for re-creating\nconflict hunks.  No other code in git parses conflict hunks.\n\nRequested-by: Stefan Monnier <monnier@iro.umontreal.ca>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://thread.gmane.org/gmane.comp.version-control.git/142374/focus=142391>.\n\nThe new series has a small conflict with ‘next’ (the cherry-pick --no-ff\nchange).  I’ll try resolving it and put up the result at\n\n git://repo.or.cz/git/jrn.git merge-diff3-label/for-next\n\n merge-recursive.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 017cafd..917397c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1347,6 +1347,7 @@ int merge_recursive(struct merge_options *o,\n \tif (!o->call_depth)\n \t\tread_cache();\n \n+\to->ancestor = \"merged common ancestors\";\n \tclean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,\n \t\t\t    &mrtree);\n \n-- \n1.7.0.2\n"}]}