git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv5 4/7] builtin/describe.c: rename `oid` to avoid variable shadowing

From
Stefan Beller <sbeller@google.com>
Date
Nov 16, 2017, 02:00 UTC
Message-ID
<20171116020039.17810-5-sbeller@google.com>
In-Reply-To
<20171116020039.17810-1-sbeller@google.com>

The function `describe` has already a variable named `oid` declared at the beginning of the function for an object id. Do not shadow that variable with a pointer to an object id.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/describe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 29075dbd0f..fd61f463cf 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -381,9 +381,9 @@ static void describe(const char *arg, int last_one)
 	}
 
 	if (!match_cnt) {
-		struct object_id *oid = &cmit->object.oid;
+		struct object_id *cmit_oid = &cmit->object.oid;
 		if (always) {
-			printf("%s", find_unique_abbrev(oid->hash, abbrev));
+			printf("%s", find_unique_abbrev(cmit_oid->hash, abbrev));
 			if (suffix)
 				printf("%s", suffix);
 			printf("\n");
@@ -392,11 +392,11 @@ static void describe(const char *arg, int last_one)
 		if (unannotated_cnt)
 			die(_("No annotated tags can describe '%s'.\n"
 			    "However, there were unannotated tags: try --tags."),
-			    oid_to_hex(oid));
+			    oid_to_hex(cmit_oid));
 		else
 			die(_("No tags can describe '%s'.\n"
 			    "Try --always, or create some tags."),
-			    oid_to_hex(oid));
+			    oid_to_hex(cmit_oid));
 	}
 
 	QSORT(all_matches, match_cnt, compare_pt);
-- 
2.15.0.128.gcadd42da22
Previous: Stefan BellerNext: Stefan Beller
Message 5 of 19 in “[PATCHv5 0/7] describe blob”
  1. Stefan BellerNov 16, 2017
  2. 1/7 t6120: fix typo in test nameStefan Beller, Nov 16, 2017
  3. 2/7 list-objects.c: factor out traverse_trees_and_blobsStefan Beller, Nov 16, 2017
  4. 3/7 revision.h: introduce blob/tree walking in order of the commitsStefan Beller, Nov 16, 2017
  5. 4/7 builtin/describe.c: rename `oid` to avoid variable shadowingStefan Beller, Nov 16, 2017
  6. 5/7 builtin/describe.c: print debug statements earlierStefan Beller, Nov 16, 2017
  7. 6/7 builtin/describe.c: factor out describe_commitStefan Beller, Nov 16, 2017
  8. 7/7 builtin/describe.c: describe a blobStefan Beller, Nov 16, 2017
  9. Junio C HamanoNov 16, 2017
  10. Stefan BellerNov 16, 2017
  11. Junio C HamanoNov 22, 2017
  12. Stefan BellerNov 22, 2017
  13. Junio C HamanoNov 24, 2017
  14. Stefan BellerNov 27, 2017
  15. Junio C HamanoNov 27, 2017
  16. Philip OakleyNov 20, 2017
  17. Junio C HamanoDec 19, 2017
  18. Stefan BellerDec 19, 2017
  19. Junio C HamanoDec 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.