{"thread":{"id":"9188","subject":"[PATCH] git log -g: Complain, but do not fail, when no reflogs are there","startedAt":"2007-07-23T23:39:50Z","lastAt":"2007-07-24T11:11:21Z","messageCount":7,"participants":["Johannes Schindelin","Junio C Hamano","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48377","messageId":"Pine.LNX.4.64.0707240039300.14781@racer.site","threadId":"9188","inReplyTo":null,"subject":"[PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-23T23:39:50Z","receivedAt":"2007-07-23T23:39:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen asking \"git log -g --all\", clearly you want to see only those refs\nthat do have reflogs, but you do not want it to fail, either.\n\nSo instead of die()ing, complain about it, but move on to the other refs.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n reflog-walk.c |    7 ++++---\n reflog-walk.h |    2 +-\n revision.c    |    7 ++++---\n 3 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex c983858..7809fad 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -136,7 +136,7 @@ void init_reflog_walk(struct reflog_walk_info** info)\n \t*info = xcalloc(sizeof(struct reflog_walk_info), 1);\n }\n \n-void add_reflog_for_walk(struct reflog_walk_info *info,\n+int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tstruct commit *commit, const char *name)\n {\n \tunsigned long timestamp = 0;\n@@ -188,7 +188,7 @@ void add_reflog_for_walk(struct reflog_walk_info *info,\n \t\t\t}\n \t\t}\n \t\tif (!reflogs || reflogs->nr == 0)\n-\t\t\tdie(\"No reflogs found for '%s'\", branch);\n+\t\t\treturn error(\"No reflogs found for '%s'\", branch);\n \t\tpath_list_insert(branch, &info->complete_reflogs)->util\n \t\t\t= reflogs;\n \t}\n@@ -200,13 +200,14 @@ void add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tif (commit_reflog->recno < 0) {\n \t\t\tfree(branch);\n \t\t\tfree(commit_reflog);\n-\t\t\treturn;\n+\t\t\treturn error(\"No reflog found for '%s'\", name);\n \t\t}\n \t} else\n \t\tcommit_reflog->recno = reflogs->nr - recno - 1;\n \tcommit_reflog->reflogs = reflogs;\n \n \tadd_commit_info(commit, commit_reflog, &info->reflogs);\n+\treturn 0;\n }\n \n void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)\ndiff --git a/reflog-walk.h b/reflog-walk.h\nindex a4f7015..7ca1438 100644\n--- a/reflog-walk.h\n+++ b/reflog-walk.h\n@@ -2,7 +2,7 @@\n #define REFLOG_WALK_H\n \n extern void init_reflog_walk(struct reflog_walk_info** info);\n-extern void add_reflog_for_walk(struct reflog_walk_info *info,\n+extern int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tstruct commit *commit, const char *name);\n extern void fake_reflog_parent(struct reflog_walk_info *info,\n \t\tstruct commit *commit);\ndiff --git a/revision.c b/revision.c\nindex 16f35c7..038693c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -118,10 +118,11 @@ static void add_pending_object_with_mode(struct rev_info *revs, struct object *o\n {\n \tif (revs->no_walk && (obj->flags & UNINTERESTING))\n \t\tdie(\"object ranges do not make sense when not walking revisions\");\n+\tif (revs->reflog_info && obj->type == OBJ_COMMIT &&\n+\t\t\tadd_reflog_for_walk(revs->reflog_info,\n+\t\t\t\t(struct commit *)obj, name))\n+\t\treturn;\n \tadd_object_array_with_mode(obj, name, &revs->pending, mode);\n-\tif (revs->reflog_info && obj->type == OBJ_COMMIT)\n-\t\tadd_reflog_for_walk(revs->reflog_info,\n-\t\t\t\t(struct commit *)obj, name);\n }\n \n void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)\n-- \n1.5.3.rc2.31.gf7d7-dirty\n"},{"id":"48396","messageId":"7vbqe2jr9m.fsf@assigned-by-dhcp.cox.net","threadId":"9188","inReplyTo":"Pine.LNX.4.64.0707240039300.14781@racer.site","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-24T05:37:57Z","receivedAt":"2007-07-24T05:37:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> When asking \"git log -g --all\", clearly you want to see only those refs\n> that do have reflogs, but you do not want it to fail, either.\n>\n> So instead of die()ing, complain about it, but move on to the other refs.\n\nHmph, do we even want to error(), I wonder...\n\nCan you tell, at that point, if there were explicit branch\nnames given originally on the command line, or the refs came\nfrom --all?\n"},{"id":"48401","messageId":"81b0412b0707240026v4321a709wcbbbd7b67a4c506b@mail.gmail.com","threadId":"9188","inReplyTo":"Pine.LNX.4.64.0707240039300.14781@racer.site","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-24T07:26:48Z","receivedAt":"2007-07-24T07:26:48Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>\n> When asking \"git log -g --all\", clearly you want to see only those refs\n> that do have reflogs, but you do not want it to fail, either.\n>\n> So instead of die()ing, complain about it, but move on to the other refs.\n>\n\nI believe you wont even see these complaints: the pager will start shortly\nafterwards and fill the screen with commits, completely hiding the errors.\n"},{"id":"48412","messageId":"Pine.LNX.4.64.0707241011090.14781@racer.site","threadId":"9188","inReplyTo":"7vbqe2jr9m.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-24T09:14:31Z","receivedAt":"2007-07-24T09:14:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 23 Jul 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > When asking \"git log -g --all\", clearly you want to see only those refs\n> > that do have reflogs, but you do not want it to fail, either.\n> >\n> > So instead of die()ing, complain about it, but move on to the other refs.\n> \n> Hmph, do we even want to error(), I wonder...\n\nMaybe not.  I thought it was some useful information, though.\n\n> Can you tell, at that point, if there were explicit branch names given \n> originally on the command line, or the refs came\n> from --all?\n\nNo:\n\n                        if (!strcmp(arg, \"--all\")) {\n                                handle_all(revs, flags);\n                                continue;\n                        }\n\nwhich calls\n\nstatic void handle_all(struct rev_info *revs, unsigned flags)\n{\n        struct all_refs_cb cb;\n        cb.all_revs = revs;\n        cb.all_flags = flags;\n        for_each_ref(handle_one_ref, &cb);\n}\n\nwhich in turn calls\n\nstatic int handle_one_ref(const char *path, const unsigned char *sha1, int flag,\n void *cb_data)\n{\n        struct all_refs_cb *cb = cb_data;\n        struct object *object = get_reference(cb->all_revs, path, sha1,\n                                              cb->all_flags);\n        add_pending_object(cb->all_revs, object, path);\n        return 0;\n}\n\nIf you do not say --all, handle_revision_arg() is called, which calls \nadd_pending_object thus:\n\n                        add_pending_object(revs, &a->object, this);\n                        add_pending_object(revs, &b->object, next);\n\nor thus\n\n        add_pending_object_with_mode(revs, object, arg, mode);\n\nSo no, there is not really a chance to see how the refs were specified at \nthe time add_pending_object() is called.\n\nCiao,\nDscho\n"},{"id":"48413","messageId":"Pine.LNX.4.64.0707241014500.14781@racer.site","threadId":"9188","inReplyTo":"81b0412b0707240026v4321a709wcbbbd7b67a4c506b@mail.gmail.com","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-24T09:16:21Z","receivedAt":"2007-07-24T09:16:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 24 Jul 2007, Alex Riesen wrote:\n\n> On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > \n> > When asking \"git log -g --all\", clearly you want to see only those refs\n> > that do have reflogs, but you do not want it to fail, either.\n> > \n> > So instead of die()ing, complain about it, but move on to the other refs.\n> > \n> \n> I believe you wont even see these complaints: the pager will start shortly\n> afterwards and fill the screen with commits, completely hiding the errors.\n\nYou can see it briefly, but it is hidden by default.  Which is a good \nthing.  If you set the pager to \"cat\" (which is happily not the default!) \nyou can see them clearly.  Until you are swamped by the rest of the \noutput.\n\nMaybe this is a feature?\n\nCiao,\nDscho\n"},{"id":"48427","messageId":"81b0412b0707240317q56e42a9bs44eb3e5ef9e796c6@mail.gmail.com","threadId":"9188","inReplyTo":"Pine.LNX.4.64.0707241014500.14781@racer.site","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-24T10:17:23Z","receivedAt":"2007-07-24T10:17:23Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Tue, 24 Jul 2007, Alex Riesen wrote:\n> > On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > >\n> > > When asking \"git log -g --all\", clearly you want to see only those refs\n> > > that do have reflogs, but you do not want it to fail, either.\n> > >\n> > > So instead of die()ing, complain about it, but move on to the other refs.\n> > >\n> >\n> > I believe you wont even see these complaints: the pager will start shortly\n> > afterwards and fill the screen with commits, completely hiding the errors.\n>\n> You can see it briefly, but it is hidden by default.  Which is a good\n> thing.  If you set the pager to \"cat\" (which is happily not the default!)\n> you can see them clearly.  Until you are swamped by the rest of the\n> output.\n>\n> Maybe this is a feature?\n>\n\nMaybe. I can't see it at all. Should I downgrade something or propose\na patch to put some delay after this error? I think not.\n\nI think second Junios suggestion, but this is of course no\ndifference to me.\n"},{"id":"48438","messageId":"Pine.LNX.4.64.0707241210170.14781@racer.site","threadId":"9188","inReplyTo":"81b0412b0707240317q56e42a9bs44eb3e5ef9e796c6@mail.gmail.com","subject":"Re: [PATCH] git log -g: Complain, but do not fail, when no reflogs are there","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-24T11:11:21Z","receivedAt":"2007-07-24T11:11:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 24 Jul 2007, Alex Riesen wrote:\n\n> On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > On Tue, 24 Jul 2007, Alex Riesen wrote:\n> > > On 7/24/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > >\n> > > > When asking \"git log -g --all\", clearly you want to see only those refs\n> > > > that do have reflogs, but you do not want it to fail, either.\n> > > >\n> > > > So instead of die()ing, complain about it, but move on to the other\n> > refs.\n> > > >\n> > >\n> > > I believe you wont even see these complaints: the pager will start shortly\n> > > afterwards and fill the screen with commits, completely hiding the errors.\n> > \n> > You can see it briefly, but it is hidden by default.  Which is a good\n> > thing.  If you set the pager to \"cat\" (which is happily not the default!)\n> > you can see them clearly.  Until you are swamped by the rest of the\n> > output.\n> > \n> > Maybe this is a feature?\n> > \n> \n> Maybe. I can't see it at all. Should I downgrade something or propose\n> a patch to put some delay after this error? I think not.\n> \n> I think second Junios suggestion, but this is of course no\n> difference to me.\n\nOkay, two votes are enough to make me reconsider.  Junio, could you please \nreplace the two \"error(...)\"s by \"-1\"s?  Only if you apply the patch, of \ncourse...\n\nCiao,\nDscho\n"}]}