{"thread":{"id":"3190","subject":"Importing diffs","startedAt":"2006-01-30T14:07:51Z","lastAt":"2006-01-31T17:01:18Z","messageCount":4,"participants":["Ian Molton","Greg KH","Daniel Barkalow","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15255","messageId":"43DE1DB7.20909@f2s.com","threadId":"3190","inReplyTo":null,"subject":"Importing diffs","fromName":"Ian Molton","fromEmail":"spyro@f2s.com","sentAt":"2006-01-30T14:07:51Z","receivedAt":"2006-01-30T14:07:51Z","isPatch":false,"sender":{"key":"spyro@f2s.com","avatar":null},"body":"Hi.\n\nis there any reason why git insists diffs be -p1 format ?\n\nit makes it hard to import a diff generated by svn (-p0).\n\nthanks!\n"},{"id":"15276","messageId":"20060130195706.GA18743@kroah.com","threadId":"3190","inReplyTo":"43DE1DB7.20909@f2s.com","subject":"Re: Importing diffs","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-01-30T19:57:06Z","receivedAt":"2006-01-30T19:57:06Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Jan 30, 2006 at 02:07:51PM +0000, Ian Molton wrote:\n> Hi.\n> \n> is there any reason why git insists diffs be -p1 format ?\n\nBecause that's the default for what the Linux kernel project uses?  :)\n\n> it makes it hard to import a diff generated by svn (-p0).\n\nI'm pretty sure that svn can output -p1 patches, I've done it in the\npast...\n\nthanks,\n\ngreg k-h\n"},{"id":"15284","messageId":"Pine.LNX.4.64.0601310015460.25300@iabervon.org","threadId":"3190","inReplyTo":"43DE1DB7.20909@f2s.com","subject":"[PATCH] Make apply accept the -pNUM option like patch does.","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2006-01-31T05:36:24Z","receivedAt":"2006-01-31T05:36:24Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This only applies to traditional diffs, not to git diffs.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n\n---\nOn Mon, 30 Jan 2006, Ian Molton wrote:\n\n> Hi.\n> \n> is there any reason why git insists diffs be -p1 format ?\n\nTry this patch. Completely untested; if it works, tell Junio. :)\n\n Documentation/git-apply.txt |    6 +++++-\n apply.c                     |    8 ++++++--\n 2 files changed, 11 insertions(+), 3 deletions(-)\n\n2490f3129103a0eae9013eb2a6f564f4a7290fbd\ndiff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt\nindex 51c7d47..75076b6 100644\n--- a/Documentation/git-apply.txt\n+++ b/Documentation/git-apply.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]\n-\t  [--no-add] [--index-info] [--allow-binary-replacement] [-z]\n+\t  [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]\n \t  [<patch>...]\n \n DESCRIPTION\n@@ -68,6 +68,10 @@ OPTIONS\n \tbackslash characters replaced with `\\t`, `\\n`, and `\\\\`,\n \trespectively.\n \n+-p<n>::\n+\tRemove <n> leading slashes from traditional diff paths. The\n+\tdefault is 1.\n+\n --apply::\n \tIf you use any of the options marked ``Turns off\n \t\"apply\"'' above, git-apply reads and outputs the\ndiff --git a/apply.c b/apply.c\nindex c471a82..79e23a7 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -19,6 +19,7 @@\n static const char *prefix;\n static int prefix_length = -1;\n \n+static int p_value = 1;\n static int allow_binary_replacement = 0;\n static int check_index = 0;\n static int write_index = 0;\n@@ -31,7 +32,7 @@ static int no_add = 0;\n static int show_index_info = 0;\n static int line_termination = '\\n';\n static const char apply_usage[] =\n-\"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] <patch>...\";\n+\"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] <patch>...\";\n \n /*\n  * For \"diff-stat\" like behaviour, we keep track of the biggest change\n@@ -217,7 +218,6 @@ static char * find_name(const char *line\n  */\n static void parse_traditional_patch(const char *first, const char *second, struct patch *patch)\n {\n-\tint p_value = 1;\n \tchar *name;\n \n \tfirst += 4;\t// skip \"--- \"\n@@ -1799,6 +1799,10 @@ int main(int argc, char **argv)\n \t\t\texcludes = x;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strncmp(arg, \"-p\", 2)) {\n+\t\t\tp_value = atoi(arg + 2);\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--no-add\")) {\n \t\t\tno_add = 1;\n \t\t\tcontinue;\n-- \n0.99.6.g3480\n"},{"id":"15305","messageId":"Pine.LNX.4.64.0601310856381.7301@g5.osdl.org","threadId":"3190","inReplyTo":"Pine.LNX.4.64.0601310015460.25300@iabervon.org","subject":"Re: [PATCH] Make apply accept the -pNUM option like patch does.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-01-31T17:01:18Z","receivedAt":"2006-01-31T17:01:18Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 31 Jan 2006, Daniel Barkalow wrote:\n>\n> This only applies to traditional diffs, not to git diffs.\n\nAlso, be careful: the default for git-apply is very different from the \ndefault for a regular \"patch\".\n\n\"patch\" without any \"-p\" at all will try to automagically figure out the \nright file, which has burnt me more than once when you have the same name \n(usually \"Makefile\") in multiple sub-directories and \"patch\" makes the \nwrong automagic guess.\n\ngit-apply with this patch will continue to use -p1. No guessing, no gray \nareas. \n\nI do believe that the right thing to do is to just make SVN output \"-p1\" \npatches (I cannot imagine that you can't do so, since -p1 is a much saner \nformat than -p0), but I guess teaching git-apply to take -pN for \ntraditional patches is fine.\n\nBut if somebody suggests we do the automatic thing that \"patch\" does, I'll \nscream. Too many times have I been burnt by patch being \"helpful\" (in \ngeneral, patch by default will try very hard to apply a patch, whether it \nmakes sense or not).\n\n\t\tLinus\n"}]}