# [PATCH] stop it from failing silently when git apply patch and show err info

2 messages from 2019-07-25 to 2019-07-25. Participants: simon gao.
Thread: https://gitlist.dev/t/51524

## simon gao, 2019-07-25 10:43

Subject: [PATCH] stop it from failing silently when git apply patch and show err info
Message-ID: <1564051425-69139-1-git-send-email-simon29rock@gmail.com>
URL: https://gitlist.dev/e/1564051425-69139-1-git-send-email-simon29rock%40gmail.com

```
Signed-off-by: simon gao <simon29rock@gmail.com>
---
 apply.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/apply.c b/apply.c
index 4992eca..47b16aa 100644
--- a/apply.c
+++ b/apply.c
@@ -2093,8 +2093,10 @@ static int use_patch(struct apply_state *state, struct patch *p)
 	/* Paths outside are not touched regardless of "--include" */
 	if (state->prefix && *state->prefix) {
 		const char *rest;
-		if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
+		if (!skip_prefix(pathname, state->prefix, &rest) || !*rest){
+			error(_("%s doesn't contain the prefix(%s)"), pathname, state->prefix);
 			return 0;
+		}
 	}
 
 	/* See if it matches any of exclude/include rule */
-- 
1.8.3.1


```

## simon gao, 2019-07-25 12:15

Subject: Re: [PATCH] stop it from failing silently when git apply patch and show err info
Message-ID: <CAGR3woXsDgYTMWcMKEXO_TkynrR3ZAYKn+fpAoThT=Ey4q+b1g@mail.gmail.com>
URL: https://gitlist.dev/e/CAGR3woXsDgYTMWcMKEXO_TkynrR3ZAYKn%2BfpAoThT%3DEy4q%2Bb1g%40mail.gmail.com
In-Reply-To: <1564051425-69139-1-git-send-email-simon29rock@gmail.com>

```
I create 001.patch in dir, ceph_master

ceph_master
|--- .git
|--- src
|--- tools
|--- ...

local project directory:
storage
|---.git
|---ceph_**.*.**
    |--- src
    |--- tools
    |--- ...

I'm trying to apply the patch, and git apply patch doesn't give me any errors.
like this
cd storage/ceph_**.*.** && git apply 001.patch
I check code and I find that root directory need to be set using "--directory"
I think we need show some info about it.

thinks


simon gao <simon29rock@gmail.com> 于2019年7月25日周四 下午6:43写道：
>
> Signed-off-by: simon gao <simon29rock@gmail.com>
> ---
>  apply.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/apply.c b/apply.c
> index 4992eca..47b16aa 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -2093,8 +2093,10 @@ static int use_patch(struct apply_state *state, struct patch *p)
>         /* Paths outside are not touched regardless of "--include" */
>         if (state->prefix && *state->prefix) {
>                 const char *rest;
> -               if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
> +               if (!skip_prefix(pathname, state->prefix, &rest) || !*rest){
> +                       error(_("%s doesn't contain the prefix(%s)"), pathname, state->prefix);
>                         return 0;
> +               }
>         }
>
>         /* See if it matches any of exclude/include rule */
> --
> 1.8.3.1
>

```
