{"thread":{"id":"18219","subject":"[PATCH 1/2] Use a common function to get the pretty name of refs","startedAt":"2009-03-09T01:06:05Z","lastAt":"2009-03-09T16:11:00Z","messageCount":4,"participants":["Daniel Barkalow","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"107419","messageId":"alpine.LNX.1.00.0903082104410.19665@iabervon.org","threadId":"18219","inReplyTo":null,"subject":"[PATCH 1/2] Use a common function to get the pretty name of refs","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-09T01:06:05Z","receivedAt":"2009-03-09T01:06:05Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"The result should be consistent between fetch and push, so we ought to\nuse the same code in both cases, even though it's short.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n builtin-fetch.c     |    6 +-----\n builtin-send-pack.c |   10 ----------\n refs.c              |   10 ++++++++++\n refs.h              |    2 ++\n 4 files changed, 13 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 1e4a3d9..f3bdeda 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -197,11 +197,7 @@ static int update_local_ref(struct ref *ref,\n \tstruct commit *current = NULL, *updated;\n \tenum object_type type;\n \tstruct branch *current_branch = branch_get(NULL);\n-\tconst char *pretty_ref = ref->name + (\n-\t\t!prefixcmp(ref->name, \"refs/heads/\") ? 11 :\n-\t\t!prefixcmp(ref->name, \"refs/tags/\") ? 10 :\n-\t\t!prefixcmp(ref->name, \"refs/remotes/\") ? 13 :\n-\t\t0);\n+\tconst char *pretty_ref = prettify_ref(ref);\n \n \t*display = 0;\n \ttype = sha1_object_info(ref->new_sha1, NULL);\ndiff --git a/builtin-send-pack.c b/builtin-send-pack.c\nindex 9072905..43b89ec 100644\n--- a/builtin-send-pack.c\n+++ b/builtin-send-pack.c\n@@ -172,16 +172,6 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)\n \t}\n }\n \n-static const char *prettify_ref(const struct ref *ref)\n-{\n-\tconst char *name = ref->name;\n-\treturn name + (\n-\t\t!prefixcmp(name, \"refs/heads/\") ? 11 :\n-\t\t!prefixcmp(name, \"refs/tags/\") ? 10 :\n-\t\t!prefixcmp(name, \"refs/remotes/\") ? 13 :\n-\t\t0);\n-}\n-\n #define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)\n \n static void print_ref_status(char flag, const char *summary, struct ref *to, struct ref *from, const char *msg)\ndiff --git a/refs.c b/refs.c\nindex b2a37e1..8f968b5 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -736,6 +736,16 @@ int check_ref_format(const char *ref)\n \t}\n }\n \n+const char *prettify_ref(const struct ref *ref)\n+{\n+\tconst char *name = ref->name;\n+\treturn name + (\n+\t\t!prefixcmp(name, \"refs/heads/\") ? 11 :\n+\t\t!prefixcmp(name, \"refs/tags/\") ? 10 :\n+\t\t!prefixcmp(name, \"refs/remotes/\") ? 13 :\n+\t\t0);\n+}\n+\n const char *ref_rev_parse_rules[] = {\n \t\"%.*s\",\n \t\"refs/%.*s\",\ndiff --git a/refs.h b/refs.h\nindex 29bdcec..68c2d16 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -79,6 +79,8 @@ extern int for_each_reflog(each_ref_fn, void *);\n #define CHECK_REF_FORMAT_WILDCARD (-3)\n extern int check_ref_format(const char *target);\n \n+extern const char *prettify_ref(const struct ref *ref);\n+\n /** rename ref, return 0 on success **/\n extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);\n \n-- \n1.6.1.286.gd33a4.dirty\n"},{"id":"107442","messageId":"alpine.DEB.1.00.0903091036420.10279@pacific.mpi-cbg.de","threadId":"18219","inReplyTo":"alpine.LNX.1.00.0903082104410.19665@iabervon.org","subject":"Re: [PATCH 1/2] Use a common function to get the pretty name of refs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-09T09:38:07Z","receivedAt":"2009-03-09T09:38:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 8 Mar 2009, Daniel Barkalow wrote:\n\n> The result should be consistent between fetch and push, so we ought to \n> use the same code in both cases, even though it's short.\n\nYou might want to mention that we cannot use skip_prefix() here, as that \nfunction does not give us any clue if something was skipped at all, and we \nmust _not_ skip multiple prefixes.\n\nCiao,\nDscho\n"},{"id":"107470","messageId":"alpine.LNX.1.00.0903091159000.19665@iabervon.org","threadId":"18219","inReplyTo":"alpine.DEB.1.00.0903091036420.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH 1/2] Use a common function to get the pretty name of refs","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-09T16:00:11Z","receivedAt":"2009-03-09T16:00:11Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Mon, 9 Mar 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Sun, 8 Mar 2009, Daniel Barkalow wrote:\n> \n> > The result should be consistent between fetch and push, so we ought to \n> > use the same code in both cases, even though it's short.\n> \n> You might want to mention that we cannot use skip_prefix() here, as that \n> function does not give us any clue if something was skipped at all, and we \n> must _not_ skip multiple prefixes.\n\nI didn't even know about the skip_prefix() function; I just moved code \naround.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"107474","messageId":"alpine.DEB.1.00.0903091710020.6358@intel-tinevez-2-302","threadId":"18219","inReplyTo":"alpine.LNX.1.00.0903091159000.19665@iabervon.org","subject":"Re: [PATCH 1/2] Use a common function to get the pretty name of refs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-03-09T16:11:00Z","receivedAt":"2009-03-09T16:11:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 9 Mar 2009, Daniel Barkalow wrote:\n\n> On Mon, 9 Mar 2009, Johannes Schindelin wrote:\n> \n> > On Sun, 8 Mar 2009, Daniel Barkalow wrote:\n> > \n> > > The result should be consistent between fetch and push, so we ought \n> > > to use the same code in both cases, even though it's short.\n> > \n> > You might want to mention that we cannot use skip_prefix() here, as \n> > that function does not give us any clue if something was skipped at \n> > all, and we must _not_ skip multiple prefixes.\n> \n> I didn't even know about the skip_prefix() function; I just moved code \n> around.\n\nBut I know the function.  And I had to look at the code to end the \nhead-scratching.  Therefore I'd like the paragraph I wrote to be part of \nthe commit message, to save other people from going bald.\n\nCiao,\nDscho\n"}]}