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

[PATCH 1/3] Change prettify_ref to prettify_refname

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 13, 2009, 21:22 UTC
Message-ID
<1242249726-8514-2-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1242249726-8514-1-git-send-email-felipe.contreras@gmail.com>
In preparation to be used when the ref object is not available
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin-fetch.c     |    2 +-
 builtin-send-pack.c |    4 ++--
 refs.c              |    3 +--
 refs.h              |    2 +-
 transport.c         |    4 ++--
 5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 3c998ea..ebd0c08 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -197,7 +197,7 @@ static int update_local_ref(struct ref *ref,
 	struct commit *current = NULL, *updated;
 	enum object_type type;
 	struct branch *current_branch = branch_get(NULL);
-	const char *pretty_ref = prettify_ref(ref);
+	const char *pretty_ref = prettify_refname(ref->name);
 
 	*display = 0;
 	type = sha1_object_info(ref->new_sha1, NULL);
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d5a1c48..b2279b0 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -174,9 +174,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
 {
 	fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
 	if (from)
-		fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to));
+		fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
 	else
-		fputs(prettify_ref(to), stderr);
+		fputs(prettify_refname(to->name), stderr);
 	if (msg) {
 		fputs(" (", stderr);
 		fputs(msg, stderr);
diff --git a/refs.c b/refs.c
index e65a3b4..e74461e 100644
--- a/refs.c
+++ b/refs.c
@@ -750,9 +750,8 @@ int check_ref_format(const char *ref)
 	}
 }
 
-const char *prettify_ref(const struct ref *ref)
+const char *prettify_refname(const char *name)
 {
-	const char *name = ref->name;
 	return name + (
 		!prefixcmp(name, "refs/heads/") ? 11 :
 		!prefixcmp(name, "refs/tags/") ? 10 :
diff --git a/refs.h b/refs.h
index 29d17a4..c11f6a6 100644
--- a/refs.h
+++ b/refs.h
@@ -80,7 +80,7 @@ extern int for_each_reflog(each_ref_fn, void *);
 #define CHECK_REF_FORMAT_WILDCARD (-3)
 extern int check_ref_format(const char *target);
 
-extern const char *prettify_ref(const struct ref *ref);
+extern const char *prettify_refname(const char *refname);
 extern char *shorten_unambiguous_ref(const char *ref, int strict);
 
 /** rename ref, return 0 on success **/
diff --git a/transport.c b/transport.c
index 3dfb03c..38c7f57 100644
--- a/transport.c
+++ b/transport.c
@@ -732,9 +732,9 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
 {
 	fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
 	if (from)
-		fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to));
+		fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
 	else
-		fputs(prettify_ref(to), stderr);
+		fputs(prettify_refname(to->name), stderr);
 	if (msg) {
 		fputs(" (", stderr);
 		fputs(msg, stderr);
-- 
1.6.3.1
Previous: Felipe ContrerasNext: Felipe Contreras
Message 2 of 7 in “log: prettier decorations”
  1. 0/3 log: prettier decorationsFelipe Contreras, May 13, 2009
  2. 1/3 Change prettify_ref to prettify_refnameFelipe Contreras, May 13, 2009
  3. 2/3 Prettify log decorations even moreFelipe Contreras, May 13, 2009
  4. 3/3 Fix test for new log decorateFelipe Contreras, May 13, 2009
  5. Jeff KingMay 13, 2009
  6. 2/2 Prettify log decorations even moreFelipe Contreras, May 13, 2009
  7. Felipe ContrerasMay 13, 2009

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.