Re: [PATCH 9/9] diff: convert struct combine_diff_path to object_id

2014-05-06 Thread Michael Haggerty
On 05/03/2014 10:12 PM, brian m. carlson wrote:
 Signed-off-by: brian m. carlson sand...@crustytoothpaste.net
 ---
  combine-diff.c | 54 +++---
  diff-lib.c | 10 +-
  diff.h |  5 +++--
  3 files changed, 35 insertions(+), 34 deletions(-)
 
 diff --git a/combine-diff.c b/combine-diff.c
 index 24ca7e2..f97eb3a 100644
 --- a/combine-diff.c
 +++ b/combine-diff.c
 [...]

This file also has two literal 40 constants in it that are probably
GIT_OID_HEXSZ.

FWIW, I glanced over all of the patches in this series (though without
systematically looking for other literal constants that should be
derived from GIT_OID_RAWSZ and GIT_OID_HEXSZ) and, aside from the
problems that I already noted, they looked OK to me.

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu
http://softwareswirl.blogspot.com/
--
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 9/9] diff: convert struct combine_diff_path to object_id

2014-05-03 Thread brian m. carlson
Signed-off-by: brian m. carlson sand...@crustytoothpaste.net
---
 combine-diff.c | 54 +++---
 diff-lib.c | 10 +-
 diff.h |  5 +++--
 3 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 24ca7e2..f97eb3a 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -34,9 +34,9 @@ static struct combine_diff_path *intersect_paths(struct 
combine_diff_path *curr,
memset(p-parent, 0,
   sizeof(p-parent[0]) * num_parent);
 
-   hashcpy(p-sha1, q-queue[i]-two-sha1);
+   hashcpy(p-sha1.oid, q-queue[i]-two-sha1);
p-mode = q-queue[i]-two-mode;
-   hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1);
+   hashcpy(p-parent[n].sha1.oid, q-queue[i]-one-sha1);
p-parent[n].mode = q-queue[i]-one-mode;
p-parent[n].status = q-queue[i]-status;
*tail = p;
@@ -67,7 +67,7 @@ static struct combine_diff_path *intersect_paths(struct 
combine_diff_path *curr,
continue;
}
 
-   hashcpy(p-parent[n].sha1, q-queue[i]-one-sha1);
+   hashcpy(p-parent[n].sha1.oid, q-queue[i]-one-sha1);
p-parent[n].mode = q-queue[i]-one-mode;
p-parent[n].status = q-queue[i]-status;
 
@@ -274,7 +274,7 @@ static struct lline *coalesce_lines(struct lline *base, int 
*lenbase,
return base;
 }
 
-static char *grab_blob(const unsigned char *sha1, unsigned int mode,
+static char *grab_blob(const struct object_id *sha1, unsigned int mode,
   unsigned long *size, struct userdiff_driver *textconv,
   const char *path)
 {
@@ -284,20 +284,20 @@ static char *grab_blob(const unsigned char *sha1, 
unsigned int mode,
if (S_ISGITLINK(mode)) {
blob = xmalloc(100);
*size = snprintf(blob, 100,
-Subproject commit %s\n, sha1_to_hex(sha1));
-   } else if (is_null_sha1(sha1)) {
+Subproject commit %s\n, 
sha1_to_hex(sha1-oid));
+   } else if (is_null_sha1(sha1-oid)) {
/* deleted blob */
*size = 0;
return xcalloc(1, 1);
} else if (textconv) {
struct diff_filespec *df = alloc_filespec(path);
-   fill_filespec(df, sha1, 1, mode);
+   fill_filespec(df, sha1-oid, 1, mode);
*size = fill_textconv(textconv, df, blob);
free_filespec(df);
} else {
-   blob = read_sha1_file(sha1, type, size);
+   blob = read_sha1_file(sha1-oid, type, size);
if (type != OBJ_BLOB)
-   die(object '%s' is not a blob!, sha1_to_hex(sha1));
+   die(object '%s' is not a blob!, 
sha1_to_hex(sha1-oid));
}
return blob;
 }
@@ -379,7 +379,7 @@ static void consume_line(void *state_, char *line, unsigned 
long len)
}
 }
 
-static void combine_diff(const unsigned char *parent, unsigned int mode,
+static void combine_diff(const struct object_id *parent, unsigned int mode,
 mmfile_t *result_file,
 struct sline *sline, unsigned int cnt, int n,
 int num_parent, int result_deleted,
@@ -904,11 +904,11 @@ static void show_combined_header(struct combine_diff_path 
*elem,
 , elem-path, line_prefix, c_meta, c_reset);
printf(%s%sindex , line_prefix, c_meta);
for (i = 0; i  num_parent; i++) {
-   abb = find_unique_abbrev(elem-parent[i].sha1,
+   abb = find_unique_abbrev(elem-parent[i].sha1.oid,
 abbrev);
printf(%s%s, i ? , : , abb);
}
-   abb = find_unique_abbrev(elem-sha1, abbrev);
+   abb = find_unique_abbrev(elem-sha1.oid, abbrev);
printf(..%s%s\n, abb, c_reset);
 
if (mode_differs) {
@@ -981,7 +981,7 @@ static void show_patch_diff(struct combine_diff_path *elem, 
int num_parent,
 
/* Read the result of merge first */
if (!working_tree_file)
-   result = grab_blob(elem-sha1, elem-mode, result_size,
+   result = grab_blob(elem-sha1, elem-mode, result_size,
   textconv, elem-path);
else {
/* Used by diff-tree to read from the working tree */
@@ -1003,12 +1003,12 @@ static void show_patch_diff(struct combine_diff_path 
*elem, int num_parent,
result = strbuf_detach(buf, NULL);
elem-mode = canon_mode(st.st_mode);
} else if (S_ISDIR(st.st_mode)) {
-   unsigned char sha1[20];
-   if (resolve_gitlink_ref(elem-path,