{"thread":{"id":"17111","subject":"patches in context format ?","startedAt":"2009-01-12T09:00:11Z","lastAt":"2009-01-12T09:57:42Z","messageCount":7,"participants":["Christian MICHON","Junio C Hamano","Teemu Likonen","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"100085","messageId":"46d6db660901120100g7f62a0c2k68c96cbfc23dab5@mail.gmail.com","threadId":"17111","inReplyTo":null,"subject":"patches in context format ?","fromName":"Christian MICHON","fromEmail":"christian.michon@gmail.com","sentAt":"2009-01-12T09:00:11Z","receivedAt":"2009-01-12T09:00:11Z","isPatch":false,"sender":{"key":"christian.michon@gmail.com","avatar":"https://gravatar.com/avatar/8a7c327b21187fbcab5c27640a49450eec72e0355dc292501197f27a5a744ec4?d=mp&s=160"},"body":"I'm maintaining a git tree of the vim project: this work can be seen\nat http://github.com/cmichon/vim\n\nvim patches do not come as unified format, but only as context format\ninstead (from a \"diff -c\").\n\nThe current solution I have is to use the original patch command,\nstage modifications and add new files. I do not like this solution,\nbecause I have to work out the commit messages out of the mbox and I\nlose reproducibility. I'm basically maintaining a subset of shell\nscripts, the original patches and an artificial way (ugly) to get\ntimestamps of modifications (for the commit dates).\n\nInstead of this complicated procedure, I'd like to use \"git apply\" or\n\"git am\", provided I can get git to support \"context output format\" as\ninput for patches ?\n\nI guess the answer is no, but has anyone on the list been working on\nthis ? is there another way to translate from \"context\" to \"unified\"\nformat ?\n\nTIA\n\n-- \nChristian\n--\nhttp://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !\n"},{"id":"100091","messageId":"7vy6xgj2jq.fsf@gitster.siamese.dyndns.org","threadId":"17111","inReplyTo":"46d6db660901120100g7f62a0c2k68c96cbfc23dab5@mail.gmail.com","subject":"Re: patches in context format ?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-12T09:28:57Z","receivedAt":"2009-01-12T09:28:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Christian MICHON\" <christian.michon@gmail.com> writes:\n\n> I'm maintaining a git tree of the vim project: this work can be seen\n> at http://github.com/cmichon/vim\n>\n> vim patches do not come as unified format, but only as context format\n> instead (from a \"diff -c\").\n> ...\n> I guess the answer is no, but has anyone on the list been working on\n> this ? is there another way to translate from \"context\" to \"unified\"\n> format ?\n\nNot that I know of.\n\nIf you want to add support for the copied context format patches to your\nworkflow, I think the first step (and easiest one) would be to find an\nexternal program that lets you convert from the copied context format to\nthe unified context format.  Perhaps \"interdiff /dev/null copied >unified\"\nwould suffice (but I haven't tested this).\n\nThen find the place that feeds \"git apply\" with a patch, and add an option\nto \"git am\" to instead do something like this:\n\n-\tgit apply --index \"$dotest/patch\"\n+\tcase \"$input_is_in_the_copied_context_format\"\n+\tyes)\n+\t\tinterdiff /dev/null \"$dotest/patch\" | git apply --index\n+\t\t;;\n+\t*)\n+\t\t# unified context as before...\n+\t\tgit apply --index \"$dotest/patch\"\n+\t\t;;\n+\tesac\n\nIn the longer term, if we were to update \"git-apply\" to support the copied\ncontext format, I think we should take the same approach.  \n\nInside read_patch_file(), you detect that the patch is in the copied\ncontext format, and convert it to the unified context format and return\nthe result.  All the rest of the program can then be left alone and you\nwill have little chance of regression.\n"},{"id":"100092","messageId":"871vv8rhpz.fsf@iki.fi","threadId":"17111","inReplyTo":"46d6db660901120100g7f62a0c2k68c96cbfc23dab5@mail.gmail.com","subject":"Re: patches in context format ?","fromName":"Teemu Likonen","fromEmail":"tlikonen@iki.fi","sentAt":"2009-01-12T09:34:00Z","receivedAt":"2009-01-12T09:34:00Z","isPatch":false,"sender":{"key":"tlikonen@iki.fi","avatar":null},"body":"Christian MICHON (2009-01-12 10:00 +0100) wrote:\n\n> is there another way to translate from \"context\" to \"unified\" format ?\n\nWell, this is not exactly the best solution for a Vim user but this is\nthe only way I know. Emacs can convert diffs between the formats. You\ndon't even need to launch Emacs, just run it in batch mode:\n\n    $ emacs --batch -Q --file input.diff \\\n        --eval '(diff-context->unified (point-min) (point-max))' \\\n        --eval '(save-buffer)'\n"},{"id":"100097","messageId":"46d6db660901120152g31d33bfevcd592ae360252804@mail.gmail.com","threadId":"17111","inReplyTo":"7vy6xgj2jq.fsf@gitster.siamese.dyndns.org","subject":"Re: patches in context format ?","fromName":"Christian MICHON","fromEmail":"christian.michon@gmail.com","sentAt":"2009-01-12T09:52:23Z","receivedAt":"2009-01-12T09:52:23Z","isPatch":false,"sender":{"key":"christian.michon@gmail.com","avatar":"https://gravatar.com/avatar/8a7c327b21187fbcab5c27640a49450eec72e0355dc292501197f27a5a744ec4?d=mp&s=160"},"body":"On Mon, Jan 12, 2009 at 10:28 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> I guess the answer is no, but has anyone on the list been working on\n>> this ? is there another way to translate from \"context\" to \"unified\"\n>> format ?\n>\n> Not that I know of.\n>\n> If you want to add support for the copied context format patches to your\n> workflow, I think the first step (and easiest one) would be to find an\n> external program that lets you convert from the copied context format to\n> the unified context format.  Perhaps \"interdiff /dev/null copied >unified\"\n> would suffice (but I haven't tested this).\n>\n\ninterdiff is exactly what I needed (I used -p and -q switches, plus a\nsubstitution for the path).\n\nThanks for this! I guess there's not really a need to add this now in\ngit-am, since I've seldom seen such context patches.\n\n-- \nChristian\n--\nhttp://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !\n"},{"id":"100098","messageId":"20090112095250.GB3079@coredump.intra.peff.net","threadId":"17111","inReplyTo":"46d6db660901120100g7f62a0c2k68c96cbfc23dab5@mail.gmail.com","subject":"Re: patches in context format ?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-12T09:52:50Z","receivedAt":"2009-01-12T09:52:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jan 12, 2009 at 10:00:11AM +0100, Christian MICHON wrote:\n\n> The current solution I have is to use the original patch command,\n> stage modifications and add new files. I do not like this solution,\n> because I have to work out the commit messages out of the mbox and I\n> lose reproducibility. I'm basically maintaining a subset of shell\n> scripts, the original patches and an artificial way (ugly) to get\n> timestamps of modifications (for the commit dates).\n> \n> Instead of this complicated procedure, I'd like to use \"git apply\" or\n> \"git am\", provided I can get git to support \"context output format\" as\n> input for patches ?\n\nMaybe this is not the nicest solution if you are going to apply a lot of\nthese patches, but you can pick up where git-am fails, run patch, and\nask it to resume:\n\n  $ git am mbox-with-context-diff\n  Applying: a minor change\n  error: No changes\n  Patch failed at 0001.\n  When you have resolved this problem run \"git am --resolved\".\n  If you would prefer to skip this patch, instead run \"git am --skip\".\n  To restore the original branch and stop patching run \"git am --abort\".\n\n  $ patch <.git/rebase-apply/patch ;# or whatever\n  $ git add -u\n  $ git am -r\n  Applying: a minor change\n\n-Peff\n"},{"id":"100099","messageId":"46d6db660901120153y23905b9dx6bfd27ffe7bce186@mail.gmail.com","threadId":"17111","inReplyTo":"871vv8rhpz.fsf@iki.fi","subject":"Re: patches in context format ?","fromName":"Christian MICHON","fromEmail":"christian.michon@gmail.com","sentAt":"2009-01-12T09:53:45Z","receivedAt":"2009-01-12T09:53:45Z","isPatch":false,"sender":{"key":"christian.michon@gmail.com","avatar":"https://gravatar.com/avatar/8a7c327b21187fbcab5c27640a49450eec72e0355dc292501197f27a5a744ec4?d=mp&s=160"},"body":"On Mon, Jan 12, 2009 at 10:34 AM, Teemu Likonen <tlikonen@iki.fi> wrote:\n> Christian MICHON (2009-01-12 10:00 +0100) wrote:\n>\n>> is there another way to translate from \"context\" to \"unified\" format ?\n>\n> Well, this is not exactly the best solution for a Vim user but this is\n> the only way I know. Emacs can convert diffs between the formats. You\n> don't even need to launch Emacs, just run it in batch mode:\n>\n>    $ emacs --batch -Q --file input.diff \\\n>        --eval '(diff-context->unified (point-min) (point-max))' \\\n>        --eval '(save-buffer)'\n>\n\nyou're asking a vim user to use emacs ? ;-)\n\nthanks for the suggestion: I'll try it at least, but I think I'll\nstick to interdiff.\n\n-- \nChristian\n--\nhttp://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !\n"},{"id":"100100","messageId":"46d6db660901120157g49aa8f8eo957cf4a0f5d279f0@mail.gmail.com","threadId":"17111","inReplyTo":"20090112095250.GB3079@coredump.intra.peff.net","subject":"Re: patches in context format ?","fromName":"Christian MICHON","fromEmail":"christian.michon@gmail.com","sentAt":"2009-01-12T09:57:42Z","receivedAt":"2009-01-12T09:57:42Z","isPatch":false,"sender":{"key":"christian.michon@gmail.com","avatar":"https://gravatar.com/avatar/8a7c327b21187fbcab5c27640a49450eec72e0355dc292501197f27a5a744ec4?d=mp&s=160"},"body":"On Mon, Jan 12, 2009 at 10:52 AM, Jeff King <peff@peff.net> wrote:\n> On Mon, Jan 12, 2009 at 10:00:11AM +0100, Christian MICHON wrote:\n>\n>> The current solution I have is to use the original patch command,\n>> stage modifications and add new files. I do not like this solution,\n>> because I have to work out the commit messages out of the mbox and I\n>> lose reproducibility. I'm basically maintaining a subset of shell\n>> scripts, the original patches and an artificial way (ugly) to get\n>> timestamps of modifications (for the commit dates).\n>>\n>> Instead of this complicated procedure, I'd like to use \"git apply\" or\n>> \"git am\", provided I can get git to support \"context output format\" as\n>> input for patches ?\n>\n> Maybe this is not the nicest solution if you are going to apply a lot of\n> these patches, but you can pick up where git-am fails, run patch, and\n> ask it to resume:\n>\n>  $ git am mbox-with-context-diff\n>  Applying: a minor change\n>  error: No changes\n>  Patch failed at 0001.\n>  When you have resolved this problem run \"git am --resolved\".\n>  If you would prefer to skip this patch, instead run \"git am --skip\".\n>  To restore the original branch and stop patching run \"git am --abort\".\n>\n>  $ patch <.git/rebase-apply/patch ;# or whatever\n>  $ git add -u\n>  $ git am -r\n>  Applying: a minor change\n>\n> -Peff\n>\n\nvim patches are in hundredth... so I guess this is too manual.\nThanks for the suggestion!\n\n-- \nChristian\n--\nhttp://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !\n"}]}