#include "blob.h"
#include "delta.h"
#include "builtin.h"
-#include "path-list.h"
+#include "string-list.h"
/*
* --check turns on checking that the working tree matches the
* the case where more than one patches touch the same file.
*/
-static struct path_list fn_table;
+static struct string_list fn_table;
static uint32_t hash_line(const char *cp, size_t len)
{
static void read_patch_file(struct strbuf *sb, int fd)
{
if (strbuf_read(sb, fd, 0) < 0)
- die("git-apply: read returned %s", strerror(errno));
+ die("git apply: read returned %s", strerror(errno));
/*
* Make sure that we have some slop in the buffer
name = orig_name;
len = strlen(name);
if (isnull)
- die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
+ die("git apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
another = find_name(line, NULL, p_value, TERM_TAB);
if (!another || memcmp(another, name, len))
- die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
+ die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
free(another);
return orig_name;
}
else {
/* expect "/dev/null" */
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
- die("git-apply: bad git-diff - expected /dev/null on line %d", linenr);
+ die("git apply: bad git-diff - expected /dev/null on line %d", linenr);
return NULL;
}
}
/*
* A hunk to change lines at the beginning would begin with
* @@ -1,L +N,M @@
+ * but we need to be careful. -U0 that inserts before the second
+ * line also has this pattern.
*
* And a hunk to add to an empty file would begin with
* @@ -0,0 +N,M @@
* In other words, a hunk that is (frag->oldpos <= 1) with or
* without leading context must match at the beginning.
*/
- match_beginning = frag->oldpos <= 1;
+ match_beginning = (!frag->oldpos ||
+ (frag->oldpos == 1 && !unidiff_zero));
/*
* A hunk without trailing lines must match at the end.
static struct patch *in_fn_table(const char *name)
{
- struct path_list_item *item;
+ struct string_list_item *item;
if (name == NULL)
return NULL;
- item = path_list_lookup(name, &fn_table);
+ item = string_list_lookup(name, &fn_table);
if (item != NULL)
return (struct patch *)item->util;
static void add_to_fn_table(struct patch *patch)
{
- struct path_list_item *item;
+ struct string_list_item *item;
/*
* Always add new_name unless patch is a deletion
* file creations and copies
*/
if (patch->new_name != NULL) {
- item = path_list_insert(patch->new_name, &fn_table);
+ item = string_list_insert(patch->new_name, &fn_table);
item->util = patch;
}
* later chunks shouldn't patch old names
*/
if ((patch->new_name == NULL) || (patch->is_rename)) {
- item = path_list_insert(patch->old_name, &fn_table);
+ item = string_list_insert(patch->old_name, &fn_table);
item->util = (struct patch *) -1;
}
}
int skipped_patch = 0;
/* FIXME - memory leak when using multiple patch files as inputs */
- memset(&fn_table, 0, sizeof(struct path_list));
+ memset(&fn_table, 0, sizeof(struct string_list));
strbuf_init(&buf, 0);
patch_input_file = filename;
read_patch_file(&buf, fd);