diff: convert fill_filespec to struct object_id
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
94a0097a41
commit
f9704c2d82
|
@ -163,7 +163,7 @@ int textconv_object(const char *path,
|
||||||
struct userdiff_driver *textconv;
|
struct userdiff_driver *textconv;
|
||||||
|
|
||||||
df = alloc_filespec(path);
|
df = alloc_filespec(path);
|
||||||
fill_filespec(df, oid->hash, oid_valid, mode);
|
fill_filespec(df, oid, oid_valid, mode);
|
||||||
textconv = get_textconv(df);
|
textconv = get_textconv(df);
|
||||||
if (!textconv) {
|
if (!textconv) {
|
||||||
free_filespec(df);
|
free_filespec(df);
|
||||||
|
|
|
@ -57,8 +57,8 @@ static void stuff_change(struct diff_options *opt,
|
||||||
|
|
||||||
one = alloc_filespec(old_name);
|
one = alloc_filespec(old_name);
|
||||||
two = alloc_filespec(new_name);
|
two = alloc_filespec(new_name);
|
||||||
fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
|
fill_filespec(one, old_oid, old_oid_valid, old_mode);
|
||||||
fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
|
fill_filespec(two, new_oid, new_oid_valid, new_mode);
|
||||||
|
|
||||||
diff_queue(&diff_queued_diff, one, two);
|
diff_queue(&diff_queued_diff, one, two);
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
|
||||||
return xcalloc(1, 1);
|
return xcalloc(1, 1);
|
||||||
} else if (textconv) {
|
} else if (textconv) {
|
||||||
struct diff_filespec *df = alloc_filespec(path);
|
struct diff_filespec *df = alloc_filespec(path);
|
||||||
fill_filespec(df, oid->hash, 1, mode);
|
fill_filespec(df, oid, 1, mode);
|
||||||
*size = fill_textconv(textconv, df, &blob);
|
*size = fill_textconv(textconv, df, &blob);
|
||||||
free_filespec(df);
|
free_filespec(df);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1022,7 +1022,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
&result_size, NULL, NULL);
|
&result_size, NULL, NULL);
|
||||||
} else if (textconv) {
|
} else if (textconv) {
|
||||||
struct diff_filespec *df = alloc_filespec(elem->path);
|
struct diff_filespec *df = alloc_filespec(elem->path);
|
||||||
fill_filespec(df, null_sha1, 0, st.st_mode);
|
fill_filespec(df, &null_oid, 0, st.st_mode);
|
||||||
result_size = fill_textconv(textconv, df, &result);
|
result_size = fill_textconv(textconv, df, &result);
|
||||||
free_filespec(df);
|
free_filespec(df);
|
||||||
} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
|
} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
|
||||||
|
|
|
@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
|
||||||
struct diff_filepair *pair;
|
struct diff_filepair *pair;
|
||||||
pair = diff_unmerge(&revs->diffopt, idx->name);
|
pair = diff_unmerge(&revs->diffopt, idx->name);
|
||||||
if (tree)
|
if (tree)
|
||||||
fill_filespec(pair->one, tree->oid.hash, 1,
|
fill_filespec(pair->one, &tree->oid, 1,
|
||||||
tree->ce_mode);
|
tree->ce_mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ static struct diff_filespec *noindex_filespec(const char *name, int mode)
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "/dev/null";
|
name = "/dev/null";
|
||||||
s = alloc_filespec(name);
|
s = alloc_filespec(name);
|
||||||
fill_filespec(s, null_sha1, 0, mode);
|
fill_filespec(s, &null_oid, 0, mode);
|
||||||
if (name == file_from_standard_input)
|
if (name == file_from_standard_input)
|
||||||
populate_from_stdin(s);
|
populate_from_stdin(s);
|
||||||
return s;
|
return s;
|
||||||
|
|
16
diff.c
16
diff.c
|
@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
|
void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
|
||||||
int sha1_valid, unsigned short mode)
|
int oid_valid, unsigned short mode)
|
||||||
{
|
{
|
||||||
if (mode) {
|
if (mode) {
|
||||||
spec->mode = canon_mode(mode);
|
spec->mode = canon_mode(mode);
|
||||||
hashcpy(spec->oid.hash, sha1);
|
oidcpy(&spec->oid, oid);
|
||||||
spec->oid_valid = sha1_valid;
|
spec->oid_valid = oid_valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
|
||||||
two = alloc_filespec(concatpath);
|
two = alloc_filespec(concatpath);
|
||||||
|
|
||||||
if (addremove != '+')
|
if (addremove != '+')
|
||||||
fill_filespec(one, oid->hash, oid_valid, mode);
|
fill_filespec(one, oid, oid_valid, mode);
|
||||||
if (addremove != '-') {
|
if (addremove != '-') {
|
||||||
fill_filespec(two, oid->hash, oid_valid, mode);
|
fill_filespec(two, oid, oid_valid, mode);
|
||||||
two->dirty_submodule = dirty_submodule;
|
two->dirty_submodule = dirty_submodule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,
|
||||||
|
|
||||||
one = alloc_filespec(concatpath);
|
one = alloc_filespec(concatpath);
|
||||||
two = alloc_filespec(concatpath);
|
two = alloc_filespec(concatpath);
|
||||||
fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
|
fill_filespec(one, old_oid, old_oid_valid, old_mode);
|
||||||
fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
|
fill_filespec(two, new_oid, new_oid_valid, new_mode);
|
||||||
one->dirty_submodule = old_dirty_submodule;
|
one->dirty_submodule = old_dirty_submodule;
|
||||||
two->dirty_submodule = new_dirty_submodule;
|
two->dirty_submodule = new_dirty_submodule;
|
||||||
p = diff_queue(&diff_queued_diff, one, two);
|
p = diff_queue(&diff_queued_diff, one, two);
|
||||||
|
|
|
@ -60,7 +60,7 @@ static int add_rename_dst(struct diff_filespec *two)
|
||||||
memmove(rename_dst + first + 1, rename_dst + first,
|
memmove(rename_dst + first + 1, rename_dst + first,
|
||||||
(rename_dst_nr - first - 1) * sizeof(*rename_dst));
|
(rename_dst_nr - first - 1) * sizeof(*rename_dst));
|
||||||
rename_dst[first].two = alloc_filespec(two->path);
|
rename_dst[first].two = alloc_filespec(two->path);
|
||||||
fill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,
|
fill_filespec(rename_dst[first].two, &two->oid, two->oid_valid,
|
||||||
two->mode);
|
two->mode);
|
||||||
rename_dst[first].pair = NULL;
|
rename_dst[first].pair = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct diff_filespec {
|
||||||
|
|
||||||
extern struct diff_filespec *alloc_filespec(const char *);
|
extern struct diff_filespec *alloc_filespec(const char *);
|
||||||
extern void free_filespec(struct diff_filespec *);
|
extern void free_filespec(struct diff_filespec *);
|
||||||
extern void fill_filespec(struct diff_filespec *, const unsigned char *,
|
extern void fill_filespec(struct diff_filespec *, const struct object_id *,
|
||||||
int, unsigned short);
|
int, unsigned short);
|
||||||
|
|
||||||
#define CHECK_SIZE_ONLY 1
|
#define CHECK_SIZE_ONLY 1
|
||||||
|
|
2
grep.c
2
grep.c
|
@ -1407,7 +1407,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver,
|
||||||
fill_filespec(df, gs->identifier, 1, 0100644);
|
fill_filespec(df, gs->identifier, 1, 0100644);
|
||||||
break;
|
break;
|
||||||
case GREP_SOURCE_FILE:
|
case GREP_SOURCE_FILE:
|
||||||
fill_filespec(df, null_sha1, 0, 0100644);
|
fill_filespec(df, &null_oid, 0, 0100644);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
die("BUG: attempt to textconv something without a path?");
|
die("BUG: attempt to textconv something without a path?");
|
||||||
|
|
|
@ -500,12 +500,12 @@ static struct commit *check_single_commit(struct rev_info *revs)
|
||||||
static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
|
static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
|
||||||
{
|
{
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
|
|
||||||
if (get_tree_entry(commit->object.oid.hash, spec->path,
|
if (get_tree_entry(commit->object.oid.hash, spec->path,
|
||||||
sha1, &mode))
|
oid.hash, &mode))
|
||||||
die("There is no path %s in the commit", spec->path);
|
die("There is no path %s in the commit", spec->path);
|
||||||
fill_filespec(spec, sha1, 1, mode);
|
fill_filespec(spec, &oid, 1, mode);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue