{"thread":{"id":"28245","subject":"[tig: PATCH] Decorate replaced commits","startedAt":"2011-08-29T09:08:30Z","lastAt":"2011-09-06T02:50:56Z","messageCount":2,"participants":["Michael J Gruber","Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"174452","messageId":"f2c76a759d9e39c32b90033cb64f677b7a2602d8.1314608820.git.git@drmicha.warpmail.net","threadId":"28245","inReplyTo":null,"subject":"[tig: PATCH] Decorate replaced commits","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-08-29T09:08:30Z","receivedAt":"2011-08-29T09:08:30Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Decorate replaced commits by \"replaced\" analogous to git.git's\n5267d29 (log: decorate \"replaced\" on to replaced commits, 2011-08-19).\n---\nShould probably follow this up with graft decorations.\n\n tig.c |   17 ++++++++++++++++-\n 1 files changed, 16 insertions(+), 1 deletions(-)\n\ndiff --git a/tig.c b/tig.c\nindex 92091ab..c9e8d1d 100644\n--- a/tig.c\n+++ b/tig.c\n@@ -26,6 +26,7 @@ struct ref {\n \tunsigned int tag:1;\t/* Is it a tag? */\n \tunsigned int ltag:1;\t/* If so, is the tag local? */\n \tunsigned int remote:1;\t/* Is it a remote ref? */\n+\tunsigned int replace:1;\t/* Is it a replace ref? */\n \tunsigned int tracked:1;\t/* Is it the remote for the current HEAD? */\n \tchar name[1];\t\t/* Ref name; tag or head names are shortened. */\n };\n@@ -444,6 +445,7 @@ LINE(MAIN_COMMIT,  \"\",\t\t\tCOLOR_DEFAULT,\tCOLOR_DEFAULT,\t0), \\\n LINE(MAIN_TAG,     \"\",\t\t\tCOLOR_MAGENTA,\tCOLOR_DEFAULT,\tA_BOLD), \\\n LINE(MAIN_LOCAL_TAG,\"\",\t\t\tCOLOR_MAGENTA,\tCOLOR_DEFAULT,\t0), \\\n LINE(MAIN_REMOTE,  \"\",\t\t\tCOLOR_YELLOW,\tCOLOR_DEFAULT,\t0), \\\n+LINE(MAIN_REPLACE, \"\",\t\t\tCOLOR_CYAN,\tCOLOR_DEFAULT,\t0), \\\n LINE(MAIN_TRACKED, \"\",\t\t\tCOLOR_YELLOW,\tCOLOR_DEFAULT,\tA_BOLD), \\\n LINE(MAIN_REF,     \"\",\t\t\tCOLOR_CYAN,\tCOLOR_DEFAULT,\t0), \\\n LINE(MAIN_HEAD,    \"\",\t\t\tCOLOR_CYAN,\tCOLOR_DEFAULT,\tA_BOLD), \\\n@@ -521,6 +523,8 @@ get_line_type_from_ref(const struct ref *ref)\n \t\treturn LINE_MAIN_TRACKED;\n \telse if (ref->remote)\n \t\treturn LINE_MAIN_REMOTE;\n+\telse if (ref->replace)\n+\t\treturn LINE_MAIN_REPLACE;\n \n \treturn LINE_MAIN_REF;\n }\n@@ -6748,6 +6752,8 @@ compare_refs(const void *ref1_, const void *ref2_)\n \t\treturn ref2->head - ref1->head;\n \tif (ref1->tracked != ref2->tracked)\n \t\treturn ref2->tracked - ref1->tracked;\n+\tif (ref1->replace != ref2->replace)\n+\t\treturn ref2->replace - ref1->replace;\n \t/* Order remotes last. */\n \tif (ref1->remote != ref2->remote)\n \t\treturn ref1->remote - ref2->remote;\n@@ -6809,6 +6815,7 @@ read_ref(char *id, size_t idlen, char *name, size_t namelen, void *data)\n \tbool tag = FALSE;\n \tbool ltag = FALSE;\n \tbool remote = FALSE;\n+\tbool replace = FALSE;\n \tbool tracked = FALSE;\n \tbool head = FALSE;\n \tint from = 0, to = refs_size - 1;\n@@ -6831,6 +6838,13 @@ read_ref(char *id, size_t idlen, char *name, size_t namelen, void *data)\n \t\tname\t+= STRING_SIZE(\"refs/remotes/\");\n \t\ttracked  = !strcmp(opt_remote, name);\n \n+\t} else if (!prefixcmp(name, \"refs/replace/\")) {\n+\t\treplace = TRUE;\n+\t\tid\t= name + strlen(\"refs/replace/\");\n+\t\tidlen\t= namelen - strlen(\"refs/replace/\");\n+\t\tname\t= \"replaced\";\n+\t\tnamelen\t= strlen(name);\n+\n \t} else if (!prefixcmp(name, \"refs/heads/\")) {\n \t\tnamelen -= STRING_SIZE(\"refs/heads/\");\n \t\tname\t+= STRING_SIZE(\"refs/heads/\");\n@@ -6849,7 +6863,7 @@ read_ref(char *id, size_t idlen, char *name, size_t namelen, void *data)\n \t * previous SHA1 with the resolved commit id; relies on the fact\n \t * git-ls-remote lists the commit id of an annotated tag right\n \t * before the commit id it points to. */\n-\twhile (from <= to) {\n+\twhile ((from <= to) && !replace) {\n \t\tsize_t pos = (to + from) / 2;\n \t\tint cmp = strcmp(name, refs[pos]->name);\n \n@@ -6881,6 +6895,7 @@ read_ref(char *id, size_t idlen, char *name, size_t namelen, void *data)\n \tref->tag = tag;\n \tref->ltag = ltag;\n \tref->remote = remote;\n+\tref->replace = replace;\n \tref->tracked = tracked;\n \tstring_copy_rev(ref->id, id);\n \n-- \n1.7.7.rc0.328.g9d6c7\n"},{"id":"174894","messageId":"CAFuPQ1LuKo-a2SJqAMBs724S786xCKwQJDk9q7VYG86NwEGGOw@mail.gmail.com","threadId":"28245","inReplyTo":"f2c76a759d9e39c32b90033cb64f677b7a2602d8.1314608820.git.git@drmicha.warpmail.net","subject":"Re: [tig: PATCH] Decorate replaced commits","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2011-09-06T02:50:56Z","receivedAt":"2011-09-06T02:50:56Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"On Mon, Aug 29, 2011 at 05:08, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> Decorate replaced commits by \"replaced\" analogous to git.git's\n> 5267d29 (log: decorate \"replaced\" on to replaced commits, 2011-08-19).\n\nThanks.\n\n> Should probably follow this up with graft decorations.\n\nYes, that'd be great.\n\n-- \nJonas Fonseca\n"}]}