{"thread":{"id":"20388","subject":"[PATCH 09/13] Allow helpers to report in \"list\" command that the ref is unchanged","startedAt":"2009-08-05T05:02:15Z","lastAt":"2009-08-05T21:18:35Z","messageCount":3,"participants":["Daniel Barkalow","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":13},"messages":[{"id":"119568","messageId":"alpine.LNX.2.00.0908050056000.2147@iabervon.org","threadId":"20388","inReplyTo":null,"subject":"[PATCH 09/13] Allow helpers to report in \"list\" command that the ref is unchanged","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-08-05T05:02:15Z","receivedAt":"2009-08-05T05:02:15Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Helpers may use a line like \"? name unchanged\" to specify that there\nis nothing new at that name, without any git-specific code to\ndetermine the correct response.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n Documentation/git-remote-helpers.txt |    4 +++-\n transport-helper.c                   |    6 ++++++\n 2 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-remote-helpers.txt b/Documentation/git-remote-helpers.txt\nindex e9aa67e..2c5130f 100644\n--- a/Documentation/git-remote-helpers.txt\n+++ b/Documentation/git-remote-helpers.txt\n@@ -70,7 +70,9 @@ CAPABILITIES\n REF LIST ATTRIBUTES\n -------------------\n \n-None are defined yet, but the caller must accept any which are supplied.\n+'unchanged'::\n+\tThis ref is unchanged since the last import or fetch, although\n+\tthe helper cannot necessarily determine what value that produced.\n \n Documentation\n -------------\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 6eee0da..956cece 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -193,6 +193,12 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)\n \t\t\t(*tail)->symref = xstrdup(buf.buf + 1);\n \t\telse if (buf.buf[0] != '?')\n \t\t\tget_sha1_hex(buf.buf, (*tail)->old_sha1);\n+\t\tif (eon) {\n+\t\t\tif (strstr(eon + 1, \"unchanged\")) {\n+\t\t\t\t(*tail)->status |= REF_STATUS_UPTODATE;\n+\t\t\t\tread_ref((*tail)->name, (*tail)->old_sha1);\n+\t\t\t}\n+\t\t}\n \t\ttail = &((*tail)->next);\n \t}\n \tstrbuf_release(&buf);\n-- \n1.6.4.rc3.27.g95032.dirty\n"},{"id":"119692","messageId":"alpine.DEB.1.00.0908052258440.8306@pacific.mpi-cbg.de","threadId":"20388","inReplyTo":"alpine.LNX.2.00.0908050056000.2147@iabervon.org","subject":"Re: [PATCH 09/13] Allow helpers to report in \"list\" command that the ref is unchanged","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-05T21:03:42Z","receivedAt":"2009-08-05T21:03:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 5 Aug 2009, Daniel Barkalow wrote:\n\n> +\t\t\tif (strstr(eon + 1, \"unchanged\")) {\n\nI guess we'll want to have a helper like this already:\n\n\tstatic int has_attribute(const char *tail, const char *attr) {\n\t\tint len;\n\n\t\tif (!tail)\n\t\t\treturn 0;\n\n\t\tlen = strlen(attr);\n\t\tfor (;;) {\n\t\t\tconst char *space = strchrnul(tail, ' ');\n\t\t\tif (len == space - tail && !strncmp(tail, attr, len))\n\t\t\t\treturn 1;\n\t\t\tif (!*space)\n\t\t\t\treturn 0;\n\t\t\ttail = space + 1;\n\t\t}\n\t}\n\nThis guards against attributes that are substrings of other attributes.  \n(You want to future-proof the attributes system, after all, i.e. handle \nhelpers returning attributes unknown to the current Git.)\n\nCiao,\nDscho\n"},{"id":"119698","messageId":"alpine.LNX.2.00.0908051717580.2147@iabervon.org","threadId":"20388","inReplyTo":"alpine.DEB.1.00.0908052258440.8306@pacific.mpi-cbg.de","subject":"Re: [PATCH 09/13] Allow helpers to report in \"list\" command that the ref is unchanged","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-08-05T21:18:35Z","receivedAt":"2009-08-05T21:18:35Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 5 Aug 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Wed, 5 Aug 2009, Daniel Barkalow wrote:\n> \n> > +\t\t\tif (strstr(eon + 1, \"unchanged\")) {\n> \n> I guess we'll want to have a helper like this already:\n> \n> \tstatic int has_attribute(const char *tail, const char *attr) {\n> \t\tint len;\n> \n> \t\tif (!tail)\n> \t\t\treturn 0;\n> \n> \t\tlen = strlen(attr);\n> \t\tfor (;;) {\n> \t\t\tconst char *space = strchrnul(tail, ' ');\n> \t\t\tif (len == space - tail && !strncmp(tail, attr, len))\n> \t\t\t\treturn 1;\n> \t\t\tif (!*space)\n> \t\t\t\treturn 0;\n> \t\t\ttail = space + 1;\n> \t\t}\n> \t}\n> \n> This guards against attributes that are substrings of other attributes.  \n> (You want to future-proof the attributes system, after all, i.e. handle \n> helpers returning attributes unknown to the current Git.)\n\nGood point.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"}]}