{"thread":{"id":"43904","subject":"[PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","startedAt":"2016-08-22T17:36:09Z","lastAt":"2016-08-26T06:32:07Z","messageCount":7,"participants":["Øystein Walle","Jeff King","Karthik Nayak"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"299854","messageId":"20160822173528.755-1-oystwa@gmail.com","threadId":"43904","inReplyTo":null,"subject":"[PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2016-08-22T17:35:28Z","receivedAt":"2016-08-22T17:36:09Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"git branch -vv will show \"gone\" next to a remote tracking branch if it\ndoes not exist. for-each-ref is suitable for parsing but had no way of\nshowing this information.\n\nThis introduces \"%(upstream:gone)\" to display \"gone\" in the formatted\noutput if the ref does not exist or an empty string otherwise, analogous\nto git branch -vv.\n\nSigned-off-by: Øystein Walle <oystwa@gmail.com>\n---\nI took the liberty of sending in a v2 on my own. Removed the last argument to\nstat_tracking_info() and used test_config instead of test_when_finished.\n\n Documentation/git-for-each-ref.txt |  5 +++--\n ref-filter.c                       |  9 ++++++++-\n t/t6300-for-each-ref.sh            | 11 +++++++++++\n 3 files changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex f57e69b..039a86b 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -114,8 +114,9 @@ upstream::\n \t`refname` above.  Additionally respects `:track` to show\n \t\"[ahead N, behind M]\" and `:trackshort` to show the terse\n \tversion: \">\" (ahead), \"<\" (behind), \"<>\" (ahead and behind),\n-\tor \"=\" (in sync).  Has no effect if the ref does not have\n-\ttracking information associated with it.\n+\tor \"=\" (in sync) and `:gone` to show \"gone\" if the remote ref\n+\tdoes not exist, or an empty string if it does. Has no effect if\n+\tthe ref does not have tracking information associated with it.\n \n push::\n \tThe name of a local ref which represents the `@{push}` location\ndiff --git a/ref-filter.c b/ref-filter.c\nindex bc551a7..757f473 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -37,7 +37,7 @@ static struct used_atom {\n \tunion {\n \t\tchar color[COLOR_MAXLEN];\n \t\tstruct align align;\n-\t\tenum { RR_NORMAL, RR_SHORTEN, RR_TRACK, RR_TRACKSHORT }\n+\t\tenum { RR_NORMAL, RR_SHORTEN, RR_TRACK, RR_TRACKSHORT, RR_GONE }\n \t\t\tremote_ref;\n \t\tstruct {\n \t\t\tenum { C_BARE, C_BODY, C_BODY_DEP, C_LINES, C_SIG, C_SUB } option;\n@@ -67,6 +67,8 @@ static void remote_ref_atom_parser(struct used_atom *atom, const char *arg)\n \t\tatom->u.remote_ref = RR_TRACK;\n \telse if (!strcmp(arg, \"trackshort\"))\n \t\tatom->u.remote_ref = RR_TRACKSHORT;\n+\telse if (!strcmp(arg, \"gone\"))\n+\t\tatom->u.remote_ref = RR_GONE;\n \telse\n \t\tdie(_(\"unrecognized format: %%(%s)\"), atom->name);\n }\n@@ -923,6 +925,11 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,\n \t\t\t*s = \">\";\n \t\telse\n \t\t\t*s = \"<>\";\n+\t} else if (atom->u.remote_ref == RR_GONE) {\n+\t\tif (stat_tracking_info(branch, &num_ours, &num_theirs, NULL) < 0)\n+\t\t\t*s = \"gone\";\n+\t\telse\n+\t\t\t*s = \"\";\n \t} else /* RR_NORMAL */\n \t\t*s = refname;\n }\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 19a2823..f99bfd0 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -383,6 +383,17 @@ test_expect_success 'Check that :track[short] works when upstream is invalid' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'Check that :gone produces expected results' '\n+\tcat >expected <<-\\EOF &&\n+gone\n+\tEOF\n+\ttest_config branch.master.merge refs/heads/does-not-exist &&\n+\tgit for-each-ref \\\n+\t\t--format=\"%(upstream:gone)\" \\\n+\t\trefs/heads >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success 'Check for invalid refname format' '\n \ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n-- \n2.9.2\n\n"},{"id":"300094","messageId":"20160824180730.mqlvhkthg4imd2vy@sigill.intra.peff.net","threadId":"43904","inReplyTo":"20160822173528.755-1-oystwa@gmail.com","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-08-24T18:07:30Z","receivedAt":"2016-08-24T18:07:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 22, 2016 at 07:35:28PM +0200, Øystein Walle wrote:\n\n> git branch -vv will show \"gone\" next to a remote tracking branch if it\n> does not exist. for-each-ref is suitable for parsing but had no way of\n> showing this information.\n> \n> This introduces \"%(upstream:gone)\" to display \"gone\" in the formatted\n> output if the ref does not exist or an empty string otherwise, analogous\n> to git branch -vv.\n> \n> Signed-off-by: Øystein Walle <oystwa@gmail.com>\n> ---\n> I took the liberty of sending in a v2 on my own. Removed the last argument to\n> stat_tracking_info() and used test_config instead of test_when_finished.\n\nWhoops, your v2 spurred me to review, but I accidentally read and\nresponded to v1.\n\nI think test_config may not be the right thing here, though; see my\nother comments.\n\n-Peff\n"},{"id":"300097","messageId":"CAFaJEqvm9Xj34t+F=KMtwRDEYhwHZ7=MRwsZ22-Gt_UPd4r72A@mail.gmail.com","threadId":"43904","inReplyTo":"20160824180730.mqlvhkthg4imd2vy@sigill.intra.peff.net","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2016-08-24T18:26:26Z","receivedAt":"2016-08-24T18:28:27Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"Hi, Peff\n\nOn 24 August 2016 at 20:07, Jeff King <peff@peff.net> wrote\n>\n> Whoops, your v2 spurred me to review, but I accidentally read and\n> responded to v1.\n>\n\nThanks for the review! I was worried this patch had been buried :-)\n\nIn the mean time, however, I have discovered that this conflicts with\nkn/ref-filter-branch-list in pu. In that topic this specific feature is\nimplemented as well. They incorporate it into %(upstream:track) instead\nof having a separate \"sub-atom\" (what's the correct nomenclature, by the\nway?) more in line with with branch -vv and your idea.\n\nI recall seeing discussions about this work earlier, but I based my\npatch on master and forgot to check pu. (It was a spur-of-the-moment\nthing fueled by a question in #git about how to parse branch -vv to\ndelete all local branch who had their remote counter-parts removed after\na fetch --prune.)\n\nUnless that topic gets rejected, or is known to not be merged for a\n_long_ while, my patch doesn't add much value.\n\nRegards,\nØsse\n"},{"id":"300104","messageId":"20160824183358.ahxcgcrg7jo2rygp@sigill.intra.peff.net","threadId":"43904","inReplyTo":"CAFaJEqvm9Xj34t+F=KMtwRDEYhwHZ7=MRwsZ22-Gt_UPd4r72A@mail.gmail.com","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-08-24T18:33:58Z","receivedAt":"2016-08-24T19:00:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 24, 2016 at 08:26:26PM +0200, Øystein Walle wrote:\n\n> In the mean time, however, I have discovered that this conflicts with\n> kn/ref-filter-branch-list in pu. In that topic this specific feature is\n> implemented as well. They incorporate it into %(upstream:track) instead\n> of having a separate \"sub-atom\" (what's the correct nomenclature, by the\n> way?) more in line with with branch -vv and your idea.\n\nAh, right. I was feeling like this was all vaguely familiar. I think it\nwould be better to push forward kn/ref-filter-branch-list. According to\nthe last \"what's cooking\", I think that topic is waiting on more review.\nIf you're willing and able to do so, that would be a big help.\n\nThanks.\n\n-Peff\n"},{"id":"300132","messageId":"CAOLa=ZSVgm_J9n9wBp_cPWF4kWtvq_8DMLWGoYTSVetOpEJnAQ@mail.gmail.com","threadId":"43904","inReplyTo":"20160824183358.ahxcgcrg7jo2rygp@sigill.intra.peff.net","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2016-08-25T05:56:12Z","receivedAt":"2016-08-25T05:56:47Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Thu, Aug 25, 2016 at 12:03 AM, Jeff King <peff@peff.net> wrote:\n> On Wed, Aug 24, 2016 at 08:26:26PM +0200, Øystein Walle wrote:\n>\n>> In the mean time, however, I have discovered that this conflicts with\n>> kn/ref-filter-branch-list in pu. In that topic this specific feature is\n>> implemented as well. They incorporate it into %(upstream:track) instead\n>> of having a separate \"sub-atom\" (what's the correct nomenclature, by the\n>> way?) more in line with with branch -vv and your idea.\n>\n\nI'm thinking more on the lines of `%(upstream)` being an atom and the\n`:track` being\nan option under that atom. I like sub-atom though ;)\n\n> Ah, right. I was feeling like this was all vaguely familiar. I think it\n> would be better to push forward kn/ref-filter-branch-list. According to\n> the last \"what's cooking\", I think that topic is waiting on more review.\n> If you're willing and able to do so, that would be a big help.\n>\n\nIt's been waiting for review for a _long_ time now.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"300134","messageId":"CAFaJEqs7vE4knXXOdKk+PxY2DZs=7BHGUJY_0a_aKF1ngnX+Lg@mail.gmail.com","threadId":"43904","inReplyTo":"CAOLa=ZSVgm_J9n9wBp_cPWF4kWtvq_8DMLWGoYTSVetOpEJnAQ@mail.gmail.com","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2016-08-25T08:45:46Z","receivedAt":"2016-08-25T08:46:34Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"On 25 August 2016 at 07:56, Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> I'm thinking more on the lines of `%(upstream)` being an atom and the\n> `:track` being an option under that atom. I like sub-atom though ;)\n>\n\nOn second thought maybe \"quark\" is better :P\n\n> On Thu, Aug 25, 2016 at 12:03 AM, Jeff King <peff@peff.net> wrote:\n>>\n>> Ah, right. I was feeling like this was all vaguely familiar. I think\n>> it would be better to push forward kn/ref-filter-branch-list.\n>> According to the last \"what's cooking\", I think that topic is waiting\n>> on more review. If you're willing and able to do so, that would be a\n>> big help.\n>>\n>\n> It's been waiting for review for a _long_ time now.\n>\n\nTo be perfectly honest my C skills and familiarity with the git source\ncode is not much to speak of. I very much want to take a close look but\nI cannot promise anything worth your time...\n\nBut if I do find something I'd like to point out should I just reply\ndirectly to the e-mails containing the patches as one usually does even\nthough they're months old at this point?\n\n\nØsse\n"},{"id":"300226","messageId":"CAOLa=ZTY0fM_Z_t8nk+je4fao8ydF1dAXmG7RzgmJyoQUj7kSg@mail.gmail.com","threadId":"43904","inReplyTo":"CAFaJEqs7vE4knXXOdKk+PxY2DZs=7BHGUJY_0a_aKF1ngnX+Lg@mail.gmail.com","subject":"Re: [PATCH v2] for-each-ref: add %(upstream:gone) to mark missing refs","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2016-08-26T06:31:29Z","receivedAt":"2016-08-26T06:32:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Hello,\n\n>> On Thu, Aug 25, 2016 at 12:03 AM, Jeff King <peff@peff.net> wrote:\n>>>\n>>> Ah, right. I was feeling like this was all vaguely familiar. I think\n>>> it would be better to push forward kn/ref-filter-branch-list.\n>>> According to the last \"what's cooking\", I think that topic is waiting\n>>> on more review. If you're willing and able to do so, that would be a\n>>> big help.\n>>>\n>>\n>> It's been waiting for review for a _long_ time now.\n>>\n>\n> To be perfectly honest my C skills and familiarity with the git source\n> code is not much to speak of. I very much want to take a close look but\n> I cannot promise anything worth your time...\n>\n> But if I do find something I'd like to point out should I just reply\n> directly to the e-mails containing the patches as one usually does even\n> though they're months old at this point?\n>\n\nNot that your review would be absolute but it definitely would be a start.\n\nReplying directly to the patches is the way to go I feel.\n\n-- \nRegards,\nKarthik Nayak\n"}]}