[PATCH] Git doesn't allow to apply a patch with empty filenames.

2015-07-06 Thread Evgen Druzhynin
git-apply fails if '-p' option truncate at least one filename in patch to zero 
size.
This solution tries to bring closer git-apply to standard Linux patch tool.
Standard patch tool skip the truncated filenames and successfully applies patch.

Evgen Druzhynin (1):
  Added ability to scip patch hunk with an empty file.

 builtin/apply.c | 16 +---
 po/bg.po| 15 ---
 po/ca.po| 15 ---
 po/de.po| 15 ---
 po/fr.po| 15 ---
 po/git.pot  | 11 ---
 po/it.po| 11 ---
 po/pt_PT.po |  7 ---
 po/ru.po| 12 
 po/sv.po| 16 
 po/vi.po| 12 
 po/zh_CN.po | 11 ---
 12 files changed, 5 insertions(+), 151 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Added ability to scip patch hunk with an empty filename.

2015-07-06 Thread Evgen Druzhynin
---
 builtin/apply.c | 16 +---
 po/bg.po| 15 ---
 po/ca.po| 15 ---
 po/de.po| 15 ---
 po/fr.po| 15 ---
 po/git.pot  | 11 ---
 po/it.po| 11 ---
 po/pt_PT.po |  7 ---
 po/ru.po| 12 
 po/sv.po| 16 
 po/vi.po| 12 
 po/zh_CN.po | 11 ---
 12 files changed, 5 insertions(+), 151 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 54aba4e..e4481b4 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1488,17 +1488,11 @@ static int find_header(const char *line, unsigned long 
size, int *hdrsize, struc
int git_hdr_len = parse_git_header(line, len, size, 
patch);
if (git_hdr_len = len)
continue;
-   if (!patch-old_name  !patch-new_name) {
-   if (!patch-def_name)
-   die(Q_(git diff header lacks filename 
information when removing 
-  %d leading pathname component 
(line %d),
-  git diff header lacks filename 
information when removing 
-  %d leading pathname components 
(line %d),
-  p_value),
-   p_value, linenr);
-   patch-old_name = xstrdup(patch-def_name);
-   patch-new_name = xstrdup(patch-def_name);
-   }
+
+   /* pass this hunk if the filename length is zero */
+   if (!patch-old_name  !patch-new_name) 
+   return -1;  
+   
if (!patch-is_delete  !patch-new_name)
die(git diff header lacks filename information 

(line %d), linenr);
diff --git a/po/bg.po b/po/bg.po
index 171f813..f2cc286 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -2373,21 +2373,6 @@ msgstr при повторното преброяване бе получен 
 msgid patch fragment without header at line %d: %.*s
 msgstr част от кръпка без заглавна част на ред %d: %.*s
 
-#: builtin/apply.c:1493
-#, c-format
-msgid 
-git diff header lacks filename information when removing %d leading pathname 
-component (line %d)
-msgid_plural 
-git diff header lacks filename information when removing %d leading pathname 
-components (line %d)
-msgstr[0] 
-След съкращаването на %d-та част от компонентите на пътя, в заглавната част 
-на „git diff“ липсва информация за име на файл (ред: %d)
-msgstr[1] 
-След съкращаването на първите %d части от компонентите на пътя, в заглавната 
-част на „git diff“ липсва информация за име на файл (ред: %d)
-
 #: builtin/apply.c:1656
 msgid new file depends on old contents
 msgstr новият файл зависи от старото съдържание на файла
diff --git a/po/ca.po b/po/ca.po
index c733483..c893285 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -2216,21 +2216,6 @@ msgstr recompte: línia inesperada: %.*s
 msgid patch fragment without header at line %d: %.*s
 msgstr fragment de pedaç sense capçalera a la línia %d: %.*s
 
-#: builtin/apply.c:1493
-#, c-format
-msgid 
-git diff header lacks filename information when removing %d leading pathname 
-component (line %d)
-msgid_plural 
-git diff header lacks filename information when removing %d leading pathname 
-components (line %d)
-msgstr[0] 
-a la capçalera de git diff li manca informació de nom de fitxer en eliminar 
-%d component de nom de camí inicial (línia %d)
-msgstr[1] 
-a la capçalera de git diff li manca informació de nom de fitxer en eliminar 
-%d components de nom de camí inicial (línia %d)
-
 #: builtin/apply.c:1656
 msgid new file depends on old contents
 msgstr el fitxer nou depèn dels continguts antics
diff --git a/po/de.po b/po/de.po
index 7d603c2..ea6b555 100644
--- a/po/de.po
+++ b/po/de.po
@@ -2257,21 +2257,6 @@ msgstr recount: unerwartete Zeile: %.*s
 msgid patch fragment without header at line %d: %.*s
 msgstr Patch-Fragment ohne Kopfbereich bei Zeile %d: %.*s
 
-#: builtin/apply.c:1493
-#, c-format
-msgid 
-git diff header lacks filename information when removing %d leading pathname 
-component (line %d)
-msgid_plural 
-git diff header lacks filename information when removing %d leading pathname 
-components (line %d)
-msgstr[0] 
-Dem Kopfbereich von \git diff\ fehlen Informationen zum Dateinamen, wenn 
-%d vorangestellter Teil des Pfades entfernt wird (Zeile %d)
-msgstr[1] 
-Dem Kopfbereich von \git diff\ fehlen Informationen zum Dateinamen, wenn 
-%d vorangestellte Teile des Pfades entfernt werden (Zeile %d)
-
 #: builtin/apply.c:1656
 msgid new file depends on old contents
 msgstr neue Datei hängt von alten Inhalten ab
diff --git a/po/fr.po