Fix PR2429: catch doubly-applied patches which create new files.
This commit is contained in:
parent
11976ebb30
commit
141aa9e579
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: common.h,v 1.8 1998/02/22 13:33:48 christos Exp $ */
|
||||
/* $NetBSD: common.h,v 1.9 1999/02/09 05:15:45 sommerfe Exp $ */
|
||||
|
||||
#define DEBUGGING
|
||||
|
||||
|
@ -110,6 +110,8 @@ EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */
|
|||
EXT int filec INIT(0); /* how many file arguments? */
|
||||
EXT char *filearg[MAXFILEC];
|
||||
EXT bool ok_to_create_file INIT(FALSE);
|
||||
EXT bool filename_is_dev_null INIT(FALSE);
|
||||
EXT bool old_file_is_dev_null INIT(FALSE);
|
||||
EXT char *bestguess INIT(Nullch); /* guess at correct filename */
|
||||
|
||||
EXT char *outname INIT(Nullch);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: inp.c,v 1.5 1998/11/06 22:40:13 christos Exp $ */
|
||||
/* $NetBSD: inp.c,v 1.6 1999/02/09 05:15:45 sommerfe Exp $ */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: inp.c,v 1.5 1998/11/06 22:40:13 christos Exp $");
|
||||
__RCSID("$NetBSD: inp.c,v 1.6 1999/02/09 05:15:45 sommerfe Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "EXTERN.h"
|
||||
|
@ -145,6 +145,11 @@ char *filename;
|
|||
fatal3("can't check out file %s from %s\n", filename, cs);
|
||||
}
|
||||
}
|
||||
if (old_file_is_dev_null && ok_to_create_file && (filestat.st_size != 0)) {
|
||||
fatal2("patch creates new file but existing file %s not empty\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
filemode = filestat.st_mode;
|
||||
if (!S_ISREG(filemode))
|
||||
fatal2("%s is not a normal file--can't patch\n", filename);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: pch.c,v 1.6 1998/11/06 22:40:13 christos Exp $ */
|
||||
/* $NetBSD: pch.c,v 1.7 1999/02/09 05:15:45 sommerfe Exp $ */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: pch.c,v 1.6 1998/11/06 22:40:13 christos Exp $");
|
||||
__RCSID("$NetBSD: pch.c,v 1.7 1999/02/09 05:15:45 sommerfe Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "EXTERN.h"
|
||||
|
@ -204,6 +204,7 @@ intuit_diff_type()
|
|||
bool no_filearg = (filearg[0] == Nullch);
|
||||
|
||||
ok_to_create_file = FALSE;
|
||||
old_file_is_dev_null = FALSE;
|
||||
Fseek(pfp, p_base, 0);
|
||||
p_input_line = p_bline - 1;
|
||||
for (;;) {
|
||||
|
@ -307,8 +308,10 @@ intuit_diff_type()
|
|||
if (no_filearg) {
|
||||
if (indtmp != Nullch)
|
||||
indname = fetchname(indtmp, strippath, ok_to_create_file);
|
||||
if (oldtmp != Nullch)
|
||||
if (oldtmp != Nullch) {
|
||||
oldname = fetchname(oldtmp, strippath, ok_to_create_file);
|
||||
old_file_is_dev_null = filename_is_dev_null;
|
||||
}
|
||||
if (newtmp != Nullch)
|
||||
newname = fetchname(newtmp, strippath, ok_to_create_file);
|
||||
if (oldname && newname) {
|
||||
|
@ -333,8 +336,10 @@ intuit_diff_type()
|
|||
else if (indtmp != Nullch)
|
||||
bestguess = fetchname(indtmp, strippath, TRUE);
|
||||
else {
|
||||
if (oldtmp != Nullch)
|
||||
if (oldtmp != Nullch) {
|
||||
oldname = fetchname(oldtmp, strippath, TRUE);
|
||||
old_file_is_dev_null = filename_is_dev_null;
|
||||
}
|
||||
if (newtmp != Nullch)
|
||||
newname = fetchname(newtmp, strippath, TRUE);
|
||||
if (oldname && newname) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: util.c,v 1.6 1998/11/06 22:40:13 christos Exp $ */
|
||||
/* $NetBSD: util.c,v 1.7 1999/02/09 05:15:45 sommerfe Exp $ */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.6 1998/11/06 22:40:13 christos Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.7 1999/02/09 05:15:45 sommerfe Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "EXTERN.h"
|
||||
|
@ -455,8 +455,11 @@ int assume_exists;
|
|||
if (debug & 128)
|
||||
say4("fetchname %s %d %d\n",at,strip_leading,assume_exists);
|
||||
#endif
|
||||
if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */
|
||||
filename_is_dev_null = FALSE;
|
||||
if (strnEQ(at, "/dev/null", 9)) { /* so files can be created by diffing */
|
||||
filename_is_dev_null = TRUE;
|
||||
return Nullch; /* against /dev/null. */
|
||||
}
|
||||
name = fullname = t = savestr(at);
|
||||
|
||||
/* Strip off up to `sleading' leading slashes and null terminate. */
|
||||
|
|
Loading…
Reference in New Issue