{"thread":{"id":"20846","subject":"[PATCH 8/8] Allow helpers to report in \"list\" command that the ref is unchanged","startedAt":"2009-09-04T02:14:04Z","lastAt":"2009-09-04T02:14:04Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"122384","messageId":"alpine.LNX.2.00.0909032213350.28290@iabervon.org","threadId":"20846","inReplyTo":null,"subject":"[PATCH 8/8] Allow helpers to report in \"list\" command that the ref is unchanged","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-09-04T02:14:04Z","receivedAt":"2009-09-04T02:14:04Z","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                   |   22 ++++++++++++++++++++++\n 2 files changed, 25 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 3825441..1a05f0b 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -166,6 +166,22 @@ static int fetch(struct transport *transport,\n \treturn -1;\n }\n \n+static int has_attribute(const char *attrs, const char *attr) {\n+\tint len;\n+\tif (!attrs)\n+\t\treturn 0;\n+\n+\tlen = strlen(attr);\n+\tfor (;;) {\n+\t\tconst char *space = strchrnul(attrs, ' ');\n+\t\tif (len == space - attrs && !strncmp(attrs, attr, len))\n+\t\t\treturn 1;\n+\t\tif (!*space)\n+\t\t\treturn 0;\n+\t\tattrs = space + 1;\n+\t}\n+}\n+\n static struct ref *get_refs_list(struct transport *transport, int for_push)\n {\n \tstruct child_process *helper;\n@@ -202,6 +218,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 (has_attribute(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.2.419.gc86f8\n"}]}