Merge branch 'bw/object-id'

Conversion from uchar[20] to struct object_id continues.

* bw/object-id: (33 commits)
  diff: rename diff_fill_sha1_info to diff_fill_oid_info
  diffcore-rename: use is_empty_blob_oid
  tree-diff: convert path_appendnew to object_id
  tree-diff: convert diff_tree_paths to struct object_id
  tree-diff: convert try_to_follow_renames to struct object_id
  builtin/diff-tree: cleanup references to sha1
  diff-tree: convert diff_tree_sha1 to struct object_id
  notes-merge: convert write_note_to_worktree to struct object_id
  notes-merge: convert verify_notes_filepair to struct object_id
  notes-merge: convert find_notes_merge_pair_ps to struct object_id
  notes-merge: convert merge_from_diffs to struct object_id
  notes-merge: convert notes_merge* to struct object_id
  tree-diff: convert diff_root_tree_sha1 to struct object_id
  combine-diff: convert find_paths_* to struct object_id
  combine-diff: convert diff_tree_combined to struct object_id
  diff: convert diff_flush_patch_id to struct object_id
  patch-ids: convert to struct object_id
  diff: finish conversion for prepare_temp_file to struct object_id
  diff: convert reuse_worktree_file to struct object_id
  diff: convert fill_filespec to struct object_id
  ...
This commit is contained in:
Junio C Hamano
2017-06-19 12:38:44 -07:00
36 changed files with 539 additions and 525 deletions

19
grep.c
View File

@ -1584,11 +1584,11 @@ static int fill_textconv_grep(struct userdiff_driver *driver,
*/
df = alloc_filespec(gs->path);
switch (gs->type) {
case GREP_SOURCE_SHA1:
case GREP_SOURCE_OID:
fill_filespec(df, gs->identifier, 1, 0100644);
break;
case GREP_SOURCE_FILE:
fill_filespec(df, null_sha1, 0, 0100644);
fill_filespec(df, &null_oid, 0, 0100644);
break;
default:
die("BUG: attempt to textconv something without a path?");
@ -1928,9 +1928,8 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
* If the identifier is non-NULL (in the submodule case) it
* will be a SHA1 that needs to be copied.
*/
case GREP_SOURCE_SHA1:
gs->identifier = xmalloc(20);
hashcpy(gs->identifier, identifier);
case GREP_SOURCE_OID:
gs->identifier = oiddup(identifier);
break;
case GREP_SOURCE_BUF:
gs->identifier = NULL;
@ -1953,7 +1952,7 @@ void grep_source_clear_data(struct grep_source *gs)
{
switch (gs->type) {
case GREP_SOURCE_FILE:
case GREP_SOURCE_SHA1:
case GREP_SOURCE_OID:
case GREP_SOURCE_SUBMODULE:
free(gs->buf);
gs->buf = NULL;
@ -1965,7 +1964,7 @@ void grep_source_clear_data(struct grep_source *gs)
}
}
static int grep_source_load_sha1(struct grep_source *gs)
static int grep_source_load_oid(struct grep_source *gs)
{
enum object_type type;
@ -1976,7 +1975,7 @@ static int grep_source_load_sha1(struct grep_source *gs)
if (!gs->buf)
return error(_("'%s': unable to read %s"),
gs->name,
sha1_to_hex(gs->identifier));
oid_to_hex(gs->identifier));
return 0;
}
@ -2022,8 +2021,8 @@ static int grep_source_load(struct grep_source *gs)
switch (gs->type) {
case GREP_SOURCE_FILE:
return grep_source_load_file(gs);
case GREP_SOURCE_SHA1:
return grep_source_load_sha1(gs);
case GREP_SOURCE_OID:
return grep_source_load_oid(gs);
case GREP_SOURCE_BUF:
return gs->buf ? 0 : -1;
case GREP_SOURCE_SUBMODULE: