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

[PATCH 2/5] interpret_branch_name: rename "cp" variable to "at"

From
Jeff King <peff@peff.net>
Date
Jan 15, 2014, 08:27 UTC
Message-ID
<20140115082732.GB19132@sigill.intra.peff.net>
In-Reply-To
<20140115082528.GA18974@sigill.intra.peff.net>

In the original version of this function, "cp" acted as a pointer to many different things. Since the refactoring in the last patch, it only marks the at-sign in the string. Let's use a more descriptive variable name.

Signed-off-by: Jeff King <peff@peff.net>
---
Obviously can be squashed with the prior refactoring, but I think
splitting it makes the diffs easier to read.
 sha1_name.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index 5db742b..958aa2e 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1117,7 +1117,7 @@ static int interpret_upstream_mark(const char *name, int namelen,
  */
 int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
 {
-	char *cp;
+	char *at;
 	int len = interpret_nth_prior_checkout(name, buf);
 
 	if (!namelen)
@@ -1132,15 +1132,15 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
 			return reinterpret(name, namelen, len, buf);
 	}
 
-	cp = strchr(name, '@');
-	if (!cp)
+	at = strchr(name, '@');
+	if (!at)
 		return -1;
 
-	len = interpret_empty_at(name, namelen, cp - name, buf);
+	len = interpret_empty_at(name, namelen, at - name, buf);
 	if (len > 0)
 		return reinterpret(name, namelen, len, buf);
 
-	len = interpret_upstream_mark(name, namelen, cp - name, buf);
+	len = interpret_upstream_mark(name, namelen, at - name, buf);
 	if (len > 0)
 		return len;
 
-- 
1.8.5.2.500.g8060133
Previous: Jeff KingNext: Jeff King
Message 8 of 12 in “BUG: check-ref-format and rev-parse can not handle branches with an @ in their name combined with @{u}”
  1. Keith DerrickJan 14, 2014
  2. Junio C HamanoJan 14, 2014
  3. Jeff KingJan 15, 2014
  4. Junio C HamanoJan 15, 2014
  5. Jeff KingJan 15, 2014
  6. 0/5 interpret_branch_name bug potpourriJeff King, Jan 15, 2014
  7. 1/5 interpret_branch_name: factor out upstream handlingJeff King, Jan 15, 2014
  8. 2/5 interpret_branch_name: rename "cp" variable to "at"Jeff King, Jan 15, 2014
  9. 3/5 interpret_branch_name: always respect "namelen" parameterJeff King, Jan 15, 2014
  10. 4/5 interpret_branch_name: avoid @{upstream} past colonJeff King, Jan 15, 2014
  11. 5/5 interpret_branch_name: find all possible @-marksJeff King, Jan 15, 2014
  12. Junio C HamanoJan 15, 2014

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.