Skip to contentSkip to conversation

Rename confusing variable in show-diff

PATCH New Junio C Hamano 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Rename confusing variable in show-diff

The show-diff command uses a variable "new" but it is always used to point at the original data recorded in the dircache before the user started editing in the working file. Rename it to "old" to avoid confusion.

To be applied on top of my previous patches:

[PATCH] Optionally tell show-diff to show only named files. [PATCH] show-diff -z option for machine readable output. [PATCH] show-diff shell safety.

---

 show-diff.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

show-diff.c: e52eee21c2f682bef2dba06445699cca8e34c63a

show-diff.c +3 -3
@@ -162,7 +162,7 @@
 		int changed;
 		unsigned long size;
 		char type[20];
-		void *new;
+		void *old;
 
 		if (1 <argc &&
 		    ! matches_pathspec(ce, argv+1, argc-1))
@@ -193,8 +193,8 @@
 		if (silent)
 			continue;
 
-		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
+		old = read_sha1_file(ce->sha1, type, &size);
+		show_differences(ce->name, old, size);
 		free(new);
 	}
 	return 0;
#1 lore raw

PATCH 1/1 (take 2) Rename confusing variable in show-diff

Oops, sorry I screwed up and sent a wrong patch. Please discard the previous one.

The show-diff command uses a variable "new" but it is always used to point at the original data recorded in the dircache before the user started editing in the working file. Rename it to "old" to avoid confusion.

To be applied on top of my previous patches:

[PATCH] Optionally tell show-diff to show only named files. [PATCH] show-diff -z option for machine readable output. [PATCH] show-diff shell safety.

---

 show-diff.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

show-diff.c: e52eee21c2f682bef2dba06445699cca8e34c63a

show-diff.c +4 -4
@@ -162,7 +162,7 @@
 		int changed;
 		unsigned long size;
 		char type[20];
-		void *new;
+		void *old;
 
 		if (1 <argc &&
 		    ! matches_pathspec(ce, argv+1, argc-1))
@@ -193,9 +193,9 @@
 		if (silent)
 			continue;
 
-		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
-		free(new);
+		old = read_sha1_file(ce->sha1, type, &size);
+		show_differences(ce->name, old, size);
+		free(old);
 	}
 	return 0;
 }