{"thread":{"id":"51524","subject":"[PATCH] stop it from failing silently when git apply patch and show err info","startedAt":"2019-07-25T10:43:55Z","lastAt":"2019-07-25T12:15:56Z","messageCount":2,"participants":["simon gao"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"379266","messageId":"1564051425-69139-1-git-send-email-simon29rock@gmail.com","threadId":"51524","inReplyTo":null,"subject":"[PATCH] stop it from failing silently when git apply patch and show err info","fromName":"simon gao","fromEmail":"simon29rock@gmail.com","sentAt":"2019-07-25T10:43:45Z","receivedAt":"2019-07-25T10:43:55Z","isPatch":true,"sender":{"key":"simon29rock@gmail.com","avatar":null},"body":"Signed-off-by: simon gao <simon29rock@gmail.com>\n---\n apply.c | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex 4992eca..47b16aa 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -2093,8 +2093,10 @@ static int use_patch(struct apply_state *state, struct patch *p)\n \t/* Paths outside are not touched regardless of \"--include\" */\n \tif (state->prefix && *state->prefix) {\n \t\tconst char *rest;\n-\t\tif (!skip_prefix(pathname, state->prefix, &rest) || !*rest)\n+\t\tif (!skip_prefix(pathname, state->prefix, &rest) || !*rest){\n+\t\t\terror(_(\"%s doesn't contain the prefix(%s)\"), pathname, state->prefix);\n \t\t\treturn 0;\n+\t\t}\n \t}\n \n \t/* See if it matches any of exclude/include rule */\n-- \n1.8.3.1\n\n"},{"id":"379271","messageId":"CAGR3woXsDgYTMWcMKEXO_TkynrR3ZAYKn+fpAoThT=Ey4q+b1g@mail.gmail.com","threadId":"51524","inReplyTo":"1564051425-69139-1-git-send-email-simon29rock@gmail.com","subject":"Re: [PATCH] stop it from failing silently when git apply patch and show err info","fromName":"simon gao","fromEmail":"simon29rock@gmail.com","sentAt":"2019-07-25T12:15:43Z","receivedAt":"2019-07-25T12:15:56Z","isPatch":true,"sender":{"key":"simon29rock@gmail.com","avatar":null},"body":"I create 001.patch in dir, ceph_master\n\nceph_master\n|--- .git\n|--- src\n|--- tools\n|--- ...\n\nlocal project directory:\nstorage\n|---.git\n|---ceph_**.*.**\n    |--- src\n    |--- tools\n    |--- ...\n\nI'm trying to apply the patch, and git apply patch doesn't give me any errors.\nlike this\ncd storage/ceph_**.*.** && git apply 001.patch\nI check code and I find that root directory need to be set using \"--directory\"\nI think we need show some info about it.\n\nthinks\n\n\nsimon gao <simon29rock@gmail.com> 于2019年7月25日周四 下午6:43写道：\n>\n> Signed-off-by: simon gao <simon29rock@gmail.com>\n> ---\n>  apply.c | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/apply.c b/apply.c\n> index 4992eca..47b16aa 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -2093,8 +2093,10 @@ static int use_patch(struct apply_state *state, struct patch *p)\n>         /* Paths outside are not touched regardless of \"--include\" */\n>         if (state->prefix && *state->prefix) {\n>                 const char *rest;\n> -               if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)\n> +               if (!skip_prefix(pathname, state->prefix, &rest) || !*rest){\n> +                       error(_(\"%s doesn't contain the prefix(%s)\"), pathname, state->prefix);\n>                         return 0;\n> +               }\n>         }\n>\n>         /* See if it matches any of exclude/include rule */\n> --\n> 1.8.3.1\n>\n"}]}