[PATCH v3 06/11] diff: rename struct diff_filespec's sha1_valid member

2016-06-24 Thread brian m. carlson
Now that this struct's sha1 member is called "oid", update the comment
and the sha1_valid member to be called "oid_valid" instead.  The
following Coccinelle semantic patch was used to implement this, followed
by the transformations in object_id.cocci:

@@
struct diff_filespec o;
@@
- o.sha1_valid
+ o.oid_valid

@@
struct diff_filespec *p;
@@
- p->sha1_valid
+ p->oid_valid

Signed-off-by: brian m. carlson 
Signed-off-by: Junio C Hamano 
---
 combine-diff.c|  4 ++--
 diff.c| 28 ++--
 diffcore-break.c  |  2 +-
 diffcore-rename.c |  4 ++--
 diffcore.h|  2 +-
 line-log.c| 10 +-
 6 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 1e1ad1c0..8e2a577b 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1269,7 +1269,7 @@ static struct diff_filepair *combined_pair(struct 
combine_diff_path *p,
pair->one[i].path = p->path;
pair->one[i].mode = p->parent[i].mode;
oidcpy(&pair->one[i].oid, &p->parent[i].oid);
-   pair->one[i].sha1_valid = !is_null_oid(&p->parent[i].oid);
+   pair->one[i].oid_valid = !is_null_oid(&p->parent[i].oid);
pair->one[i].has_more_entries = 1;
}
pair->one[num_parent - 1].has_more_entries = 0;
@@ -1277,7 +1277,7 @@ static struct diff_filepair *combined_pair(struct 
combine_diff_path *p,
pair->two->path = p->path;
pair->two->mode = p->mode;
oidcpy(&pair->two->oid, &p->oid);
-   pair->two->sha1_valid = !is_null_oid(&p->oid);
+   pair->two->oid_valid = !is_null_oid(&p->oid);
return pair;
 }
 
diff --git a/diff.c b/diff.c
index ae9edc30..9abb54ad 100644
--- a/diff.c
+++ b/diff.c
@@ -1933,7 +1933,7 @@ static void show_dirstat(struct diff_options *options)
 
name = p->two->path ? p->two->path : p->one->path;
 
-   if (p->one->sha1_valid && p->two->sha1_valid)
+   if (p->one->oid_valid && p->two->oid_valid)
content_changed = oidcmp(&p->one->oid, &p->two->oid);
else
content_changed = 1;
@@ -2640,7 +2640,7 @@ void fill_filespec(struct diff_filespec *spec, const 
unsigned char *sha1,
if (mode) {
spec->mode = canon_mode(mode);
hashcpy(spec->oid.hash, sha1);
-   spec->sha1_valid = sha1_valid;
+   spec->oid_valid = sha1_valid;
}
 }
 
@@ -2766,7 +2766,7 @@ int diff_populate_filespec(struct diff_filespec *s, 
unsigned int flags)
if (S_ISGITLINK(s->mode))
return diff_populate_gitlink(s, size_only);
 
-   if (!s->sha1_valid ||
+   if (!s->oid_valid ||
reuse_worktree_file(s->path, s->oid.hash, 0)) {
struct strbuf buf = STRBUF_INIT;
struct stat st;
@@ -2915,7 +2915,7 @@ static struct diff_tempfile *prepare_temp_file(const char 
*name,
}
 
if (!S_ISGITLINK(one->mode) &&
-   (!one->sha1_valid ||
+   (!one->oid_valid ||
 reuse_worktree_file(name, one->oid.hash, 1))) {
struct stat st;
if (lstat(name, &st) < 0) {
@@ -2928,16 +2928,16 @@ static struct diff_tempfile *prepare_temp_file(const 
char *name,
if (strbuf_readlink(&sb, name, st.st_size) < 0)
die_errno("readlink(%s)", name);
prep_temp_blob(name, temp, sb.buf, sb.len,
-  (one->sha1_valid ?
+  (one->oid_valid ?
one->oid.hash : null_sha1),
-  (one->sha1_valid ?
+  (one->oid_valid ?
one->mode : S_IFLNK));
strbuf_release(&sb);
}
else {
/* we can borrow from the file in the work tree */
temp->name = name;
-   if (!one->sha1_valid)
+   if (!one->oid_valid)
sha1_to_hex_r(temp->hex, null_sha1);
else
sha1_to_hex_r(temp->hex, one->oid.hash);
@@ -3134,7 +3134,7 @@ static void run_diff_cmd(const char *pgm,
 static void diff_fill_sha1_info(struct diff_filespec *one)
 {
if (DIFF_FILE_VALID(one)) {
-   if (!one->sha1_valid) {
+   if (!one->oid_valid) {
struct stat st;
if (one->is_stdin) {
oidclr(&one->oid);
@@ -4172,11 +4172,11 @@ int diff_unmodified_pair(struct diff_filepair *p)
/* both are valid and point at the same path.  that is, we are
 * dealing with a change.
 */
-   if (one->sha1_valid && two->sha1_valid &&
+   if (one->oid_valid

Re: [PATCH v3 06/11] diff: rename struct diff_filespec's sha1_valid member

2016-06-24 Thread Junio C Hamano
"brian m. carlson"  writes:


> @@
> struct diff_filespec o;
> @@
> - o.sha1_valid
> + o.oid_valid
>
> @@
> struct diff_filespec *p;
> @@
> - p->sha1_valid
> + p->oid_valid

Totally offtopic (from Git's point of view), but why does Coccinelle
need both of these?  I recall that between v1 and v2 there were some
confusing discussions about the order of these equivalent conversions
mattering and the tool producing an incorrect conversion in v1.

--
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


Re: [PATCH v3 06/11] diff: rename struct diff_filespec's sha1_valid member

2016-06-24 Thread brian m. carlson
On Fri, Jun 24, 2016 at 05:29:18PM -0700, Junio C Hamano wrote:
> "brian m. carlson"  writes:
> 
> 
> > @@
> > struct diff_filespec o;
> > @@
> > - o.sha1_valid
> > + o.oid_valid
> >
> > @@
> > struct diff_filespec *p;
> > @@
> > - p->sha1_valid
> > + p->oid_valid
> 
> Totally offtopic (from Git's point of view), but why does Coccinelle
> need both of these?  I recall that between v1 and v2 there were some
> confusing discussions about the order of these equivalent conversions
> mattering and the tool producing an incorrect conversion in v1.

As I understand it, Coccinelle doesn't transform . into ->.  Granted,
the latter is a special case of the former, but it might break workflows
where you're trying to convert an inline struct to a pointer to struct
or such.  It errs on the side of you being more explicit to allow more
flexibility in usage.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature