{"thread":{"id":"50819","subject":"[GSoC] Unify ref-filter formats with other --pretty formats","startedAt":"2019-03-25T19:27:04Z","lastAt":"2019-04-01T12:59:00Z","messageCount":9,"participants":["Kapil Jain","Olga Telezhnaya","Thomas Gummerer"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"372459","messageId":"CAMknYEPrrpxESK0onwTHRbVwcZE2YQpT=RVzjb9JfEBEXt4NRA@mail.gmail.com","threadId":"50819","inReplyTo":null,"subject":"[GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Kapil Jain","fromEmail":"jkapil.cs@gmail.com","sentAt":"2019-03-25T19:26:50Z","receivedAt":"2019-03-25T19:27:04Z","isPatch":false,"sender":{"key":"jkapil.cs@gmail.com","avatar":null},"body":"Hi,\n\nBelow are some two queries concerning\nhttps://git.github.io/SoC-2019-Ideas/#unify-ref-filter-formats-with-other---pretty-formats\n\nQ1)\n\nIn pretty.h & pretty.c:\nvoid get_commit_format(const char *arg, struct rev_info *);\nThis function Parses given arguments from \"arg\", checks it for\ncorrectness and * fill struct rev_info.\n\nIn ref-filter.h & ref-filter.c:\nint verify_ref_format(struct ref_format *format);\nThis function is Used to verify if the given format is correct and to\nparse out the used atoms.\n\nNow, the verify_ref_format function can be used inside\nget_commit_format function, hence reusing logic.\nIs this a correct example to work on, for this project ?\nIf not, please point out an example so as to understand the problem\nstatement better.\n\nOther than this I can't find any other example, for this project in\npretty.* and ref-filter.*\nPerhaps some examples could be found in command specific files, right ?\n\nQ2)\nAbout a recurring term 'atom' in ref-filter and pretty:\nwhat is atom ? is it a piece of a whole document ? and what is meant\nby used atoms ?\n\nThanks.\n"},{"id":"372472","messageId":"CAL21Bmn0BQirS=vyTRHBx_kfuEp1JY4uw2wkjm5w_pgwgjA5iA@mail.gmail.com","threadId":"50819","inReplyTo":"CAMknYEPrrpxESK0onwTHRbVwcZE2YQpT=RVzjb9JfEBEXt4NRA@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2019-03-25T21:17:56Z","receivedAt":"2019-03-25T21:18:11Z","isPatch":false,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"пн, 25 мар. 2019 г. в 22:27, Kapil Jain <jkapil.cs@gmail.com>:\n>\n> Hi,\n>\n> Below are some two queries concerning\n> https://git.github.io/SoC-2019-Ideas/#unify-ref-filter-formats-with-other---pretty-formats\n>\n> Q1)\n>\n> In pretty.h & pretty.c:\n> void get_commit_format(const char *arg, struct rev_info *);\n> This function Parses given arguments from \"arg\", checks it for\n> correctness and * fill struct rev_info.\n>\n> In ref-filter.h & ref-filter.c:\n> int verify_ref_format(struct ref_format *format);\n> This function is Used to verify if the given format is correct and to\n> parse out the used atoms.\n>\n> Now, the verify_ref_format function can be used inside\n> get_commit_format function, hence reusing logic.\n> Is this a correct example to work on, for this project ?\n\nHi! Yes, in my opinion your example looks like good starting point.\n\n> If not, please point out an example so as to understand the problem\n> statement better.\n>\n> Other than this I can't find any other example, for this project in\n> pretty.* and ref-filter.*\n> Perhaps some examples could be found in command specific files, right ?\n\nOther parts of the project are about reusing other ref-filter logic.\nFor example, we could try to reuse format_ref_array_item() from\nref-filter.h. I haven't dig into pretty.c logic much, but I guess it\nis possible to translate \"pretty\" formatting commands to ref-filter\nones. That will allow us to remove similar logic from pretty.c. Our\nfinal goal is to minimise code duplication and to have one unified\ninterface to extract all needed data from object and to print it\nproperly.\n\n>\n> Q2)\n> About a recurring term 'atom' in ref-filter and pretty:\n> what is atom ? is it a piece of a whole document ? and what is meant\n> by used atoms ?\n\nI had the same question in my beginning. Please have a look at [1].\nAnother good question - what is object. You could ensure that you\nunderstand this by reading [2].\n\n>\n> Thanks.\n\n[1] https://git-scm.com/docs/git-for-each-ref#_field_names\n[2] https://git-scm.com/book/en/v2/Git-Internals-Git-Objects\n"},{"id":"372581","messageId":"CAMknYENndiGBkC75aaYwWQZ0rkR5Nn=2L8f-PTzBNOXmhhHWZA@mail.gmail.com","threadId":"50819","inReplyTo":"CAL21Bmn0BQirS=vyTRHBx_kfuEp1JY4uw2wkjm5w_pgwgjA5iA@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Kapil Jain","fromEmail":"jkapil.cs@gmail.com","sentAt":"2019-03-27T17:01:26Z","receivedAt":"2019-03-27T17:01:41Z","isPatch":false,"sender":{"key":"jkapil.cs@gmail.com","avatar":null},"body":"> On Tue, Mar 26, 2019 at 2:48 AM Olga Telezhnaya <olyatelezhnaya@gmail.com> wrote:\n>> Kapil Jain <jkapil.cs@gmail.com> wrote:\n> > Now, the verify_ref_format function can be used inside\n> > get_commit_format function, hence reusing logic.\n> > Is this a correct example to work on, for this project ?\n>\n> Hi! Yes, in my opinion your example looks like good starting point.\n\nI read through the code of both functions, and I think they are different.\nPlease point out if I missed to see the similarity.\n\nor may be it seemed that way, because they both deal with different formats.\nSo, first should a translating function (pretty to ref-filter) be written ?\n\n\n> > Other than this I can't find any other example, for this project in\n> > pretty.* and ref-filter.*\n> > Perhaps some examples could be found in command specific files, right ?\n>\n> Other parts of the project are about reusing other ref-filter logic.\n\nSo, the project is not limited to reusing ref-filter logics in pretty,\nit is about reusing ref-filter logic wherever possible, right ?\n\n> For example, we could try to reuse format_ref_array_item() from\n> ref-filter.h.\n\nwhere can format_ref_array_item() be reused ?\n\n> I haven't dig into pretty.c logic much, but I guess it\n> is possible to translate \"pretty\" formatting commands to ref-filter\n> ones. That will allow us to remove similar logic from pretty.c. Our\n> final goal is to minimise code duplication and to have one unified\n> interface to extract all needed data from object and to print it\n> properly.\n\nI looked, and yes some, but not all pretty formats are translatable.\nFor example: %GP, %p, %P. are not translatable to ref-filter. or is\nthere a workaround to translate them ?\n\nIt looks like to reuse ref-filter logic, a translator from pretty to\nref-filter needs to be built.\nSo, building a translator would be a starting point ?\nand then second step would be to recognise places where ref-filter can\nbe reused, right ?\n\n> > what is atom ? is it a piece of a whole document ? and what is meant\n> > by used atoms ?\n>\n> I had the same question in my beginning. Please have a look at [1].\n> Another good question - what is object. You could ensure that you\n> understand this by reading [2].\n>\n> [1] https://git-scm.com/docs/git-for-each-ref#_field_names\n> [2] https://git-scm.com/book/en/v2/Git-Internals-Git-Objects\n\nThanks, this helped.\n"},{"id":"372638","messageId":"CAL21Bmm+KVsBWm8BJoqMP6LLBr1620quyTO4K7=yPoNWkvvxUg@mail.gmail.com","threadId":"50819","inReplyTo":"CAMknYENndiGBkC75aaYwWQZ0rkR5Nn=2L8f-PTzBNOXmhhHWZA@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2019-03-28T17:43:57Z","receivedAt":"2019-03-28T17:44:12Z","isPatch":false,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"ср, 27 мар. 2019 г. в 20:01, Kapil Jain <jkapil.cs@gmail.com>:\n>\n> > On Tue, Mar 26, 2019 at 2:48 AM Olga Telezhnaya <olyatelezhnaya@gmail.com> wrote:\n> >> Kapil Jain <jkapil.cs@gmail.com> wrote:\n> > > Now, the verify_ref_format function can be used inside\n> > > get_commit_format function, hence reusing logic.\n> > > Is this a correct example to work on, for this project ?\n> >\n> > Hi! Yes, in my opinion your example looks like good starting point.\n>\n> I read through the code of both functions, and I think they are different.\n> Please point out if I missed to see the similarity.\n>\n> or may be it seemed that way, because they both deal with different formats.\n> So, first should a translating function (pretty to ref-filter) be written ?\n>\n>\n> > > Other than this I can't find any other example, for this project in\n> > > pretty.* and ref-filter.*\n> > > Perhaps some examples could be found in command specific files, right ?\n> >\n> > Other parts of the project are about reusing other ref-filter logic.\n>\n> So, the project is not limited to reusing ref-filter logics in pretty,\n> it is about reusing ref-filter logic wherever possible, right ?\n>\n> > For example, we could try to reuse format_ref_array_item() from\n> > ref-filter.h.\n>\n> where can format_ref_array_item() be reused ?\n>\n> > I haven't dig into pretty.c logic much, but I guess it\n> > is possible to translate \"pretty\" formatting commands to ref-filter\n> > ones. That will allow us to remove similar logic from pretty.c. Our\n> > final goal is to minimise code duplication and to have one unified\n> > interface to extract all needed data from object and to print it\n> > properly.\n>\n> I looked, and yes some, but not all pretty formats are translatable.\n> For example: %GP, %p, %P. are not translatable to ref-filter. or is\n> there a workaround to translate them ?\n\nI will try to answer to all your questions here in general way.\nThomas, Christian, please correct me if you disagree.\nOur main goal is to simplify codebase, get rid of duplication of\nsimilar logic and, as a result, simplify adding new functionality. We\nalso need to save backward compatibility, so we can't just delete some\ncommands, rewrite them and change their interface (unfortunately). You\nare free to suggest your own ideas how to achieve these goals, and you\nare free to choose exact tasks. Yes, you are not limited only to\npretty.c, but it is a good place where to start.\n\nI was an intern in winter 2017-2018 and I was trying to get rid of\nformatting logic in cat-file. You may try to do same thing in\npretty.c. I guess it's easier to think how to reuse ref-filter in\npretty.c because ref-filter has the most general interface between all\nthese files. But, if you are sure that you have better idea - I am\nstrongly recommend you to share it with the mailing list.\n\nUnfortunately, I can't consult you properly about structure of\npretty.c. I guess that would be your first task of the internship to\ndive into it and think how to improve it. By the way, you could try to\nmake more detailed documentation and that could be one of your first\ncontributions. It will help you to understand the system better, and\nother contributors will be happy to read it.\n\n>\n> It looks like to reuse ref-filter logic, a translator from pretty to\n> ref-filter needs to be built.\n> So, building a translator would be a starting point ?\n> and then second step would be to recognise places where ref-filter can\n> be reused, right ?\n>\n> > > what is atom ? is it a piece of a whole document ? and what is meant\n> > > by used atoms ?\n> >\n> > I had the same question in my beginning. Please have a look at [1].\n> > Another good question - what is object. You could ensure that you\n> > understand this by reading [2].\n> >\n> > [1] https://git-scm.com/docs/git-for-each-ref#_field_names\n> > [2] https://git-scm.com/book/en/v2/Git-Internals-Git-Objects\n>\n> Thanks, this helped.\n"},{"id":"372701","messageId":"CAMknYENqM1Q_2v+0_DJtw41M85otpYzbVbbKPyh2NVZ++u=fpg@mail.gmail.com","threadId":"50819","inReplyTo":"CAL21Bmm+KVsBWm8BJoqMP6LLBr1620quyTO4K7=yPoNWkvvxUg@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Kapil Jain","fromEmail":"jkapil.cs@gmail.com","sentAt":"2019-03-29T13:53:54Z","receivedAt":"2019-03-29T13:54:36Z","isPatch":false,"sender":{"key":"jkapil.cs@gmail.com","avatar":null},"body":"On Thu, Mar 28, 2019 at 11:14 PM Olga Telezhnaya\n<olyatelezhnaya@gmail.com> wrote:\n>\n> Unfortunately, I can't consult you properly about structure of\n> pretty.c. I guess that would be your first task of the internship to\n> dive into it and think how to improve it. By the way, you could try to\n> make more detailed documentation and that could be one of your first\n> contributions. It will help you to understand the system better, and\n> other contributors will be happy to read it.\n\nok, i will be reading pretty.c and will document its structure at\nrequired places.\n"},{"id":"372835","messageId":"CAMknYEPN2rPsX8CcJVosi-S1W8bLTmMMvgS8E-SwyR74gevtcA@mail.gmail.com","threadId":"50819","inReplyTo":"CAMknYENqM1Q_2v+0_DJtw41M85otpYzbVbbKPyh2NVZ++u=fpg@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Kapil Jain","fromEmail":"jkapil.cs@gmail.com","sentAt":"2019-03-31T17:45:40Z","receivedAt":"2019-03-31T17:45:54Z","isPatch":false,"sender":{"key":"jkapil.cs@gmail.com","avatar":null},"body":"On Fri, Mar 29, 2019 at 7:23 PM Kapil Jain <jkapil.cs@gmail.com> wrote:\n>\n> On Thu, Mar 28, 2019 at 11:14 PM Olga Telezhnaya\n> <olyatelezhnaya@gmail.com> wrote:\n> >\n> > Unfortunately, I can't consult you properly about structure of\n> > pretty.c. I guess that would be your first task of the internship to\n> > dive into it and think how to improve it. By the way, you could try to\n> > make more detailed documentation and that could be one of your first\n> > contributions. It will help you to understand the system better, and\n> > other contributors will be happy to read it.\n>\n\ni traced the cmd_log() to understand the point at which pretty.c could\nbe used, i only got to userformat_find_requirements().\n\nstruct userformat_want {\n    unsigned notes:1;\n    unsigned source:1;\n};\n\nwhat are notes and source flags used for ?\n\nolga: what approach did you follow to figure which logic in cat-file\nwas redundant and that ref-filter could be reused there ?\ndoes it include picking any file, go through it entirely and then pick\nplaces to be replaced by ref-filter logic ?\n"},{"id":"372840","messageId":"20190331184930.GV32487@hank.intra.tgummerer.com","threadId":"50819","inReplyTo":"CAMknYEPN2rPsX8CcJVosi-S1W8bLTmMMvgS8E-SwyR74gevtcA@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2019-03-31T18:49:30Z","receivedAt":"2019-03-31T18:49:36Z","isPatch":false,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"On 03/31, Kapil Jain wrote:\n> On Fri, Mar 29, 2019 at 7:23 PM Kapil Jain <jkapil.cs@gmail.com> wrote:\n> >\n> > On Thu, Mar 28, 2019 at 11:14 PM Olga Telezhnaya\n> > <olyatelezhnaya@gmail.com> wrote:\n> > >\n> > > Unfortunately, I can't consult you properly about structure of\n> > > pretty.c. I guess that would be your first task of the internship to\n> > > dive into it and think how to improve it. By the way, you could try to\n> > > make more detailed documentation and that could be one of your first\n> > > contributions. It will help you to understand the system better, and\n> > > other contributors will be happy to read it.\n> >\n> \n> i traced the cmd_log() to understand the point at which pretty.c could\n> be used, i only got to userformat_find_requirements().\n> \n> struct userformat_want {\n>     unsigned notes:1;\n>     unsigned source:1;\n> };\n> \n> what are notes and source flags used for ?\n\nIf you look at what userformat_find_requirements() does, calls\nstrbuf_expand(), which in turn calls userformat_want_item(), which\nfills the 'userformat_want' struct based on the strbuf that has been\npassed.\n\nNow if we look at the caller of userformat_find_requirements(), which\nis cmd_log_init_finish(), you can see where 'w.notes' and 'w.source'\nis used. \n\nJust this parsing is probably not something that the ref-filter API\ncan help too much with.\n\nI unfortunately don't have much experience with the pretty, or the\nref-filter API.  But rather than going into the details of the code\nalready, I'd suggest first looking at what you actually want to\nreplace (see for example the PRETTY FORMATS section in 'man git-log',\nwhat which verbs you can use in the ref-filter (see 'man\ngit-for-each-ref') to achieve the same thing.\n\nThen you can see how one format is implemented in 'pretty.c', and see\nhow a similar thing using the ref-filter is implemented in\n'ref-filter.c'.\n\nE.g. the \"%(objectname:short) %(contents:subject)\" (this is missing\ncoloring, but just to get you the idea) is similar to\n'--pretty=oneline'.  Now you can try to find how 'oneline' is\nimplemented in 'pretty.c', and you could translate that to use the\n'ref-filter' API.\n"},{"id":"372843","messageId":"CAL21Bmk+=id0jat1O1vQLXBV=snXgK81qFit8_xXNogQM31Pyw@mail.gmail.com","threadId":"50819","inReplyTo":"CAMknYEPN2rPsX8CcJVosi-S1W8bLTmMMvgS8E-SwyR74gevtcA@mail.gmail.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2019-03-31T19:28:50Z","receivedAt":"2019-03-31T19:29:05Z","isPatch":false,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"вс, 31 мар. 2019 г. в 20:45, Kapil Jain <jkapil.cs@gmail.com>:\n>\n> On Fri, Mar 29, 2019 at 7:23 PM Kapil Jain <jkapil.cs@gmail.com> wrote:\n> >\n> > On Thu, Mar 28, 2019 at 11:14 PM Olga Telezhnaya\n> > <olyatelezhnaya@gmail.com> wrote:\n> > >\n> > > Unfortunately, I can't consult you properly about structure of\n> > > pretty.c. I guess that would be your first task of the internship to\n> > > dive into it and think how to improve it. By the way, you could try to\n> > > make more detailed documentation and that could be one of your first\n> > > contributions. It will help you to understand the system better, and\n> > > other contributors will be happy to read it.\n> >\n>\n> i traced the cmd_log() to understand the point at which pretty.c could\n> be used, i only got to userformat_find_requirements().\n>\n> struct userformat_want {\n>     unsigned notes:1;\n>     unsigned source:1;\n> };\n>\n> what are notes and source flags used for ?\n>\n> olga: what approach did you follow to figure which logic in cat-file\n> was redundant and that ref-filter could be reused there ?\n> does it include picking any file, go through it entirely and then pick\n> places to be replaced by ref-filter logic ?\n\nI just explored how the code works. You could see my commits here [1].\nOh, that's funny, I forgot that I started from creating pretty.h. I\ncould choose between pretty and cat-file, and I made the choice\nrandomly.\n\nIn cat-file, interface was so close to ref-filter, but the way of\nobtaining data was different, and formatting logic was coded twice. We\ndecided that cat-file gets the data more efficiently, and I changed\nref-filter logic, it works faster now. Then I needed to reuse\nformatting logic, and I am still working on that (do not worry, it\nmust not be a reason for merge conflicts).\n\nI guess you will have another workflow: I don't know anything about\nhow pretty gets the data, but the interface differs a lot. So you will\nhave another tasks.\n\nIf you have enough skills to debug the code, I definitely suggest you\nto go through all formatting process step-by-step (both for pretty and\nref-filter) for different type of input, that will explain you a lot\nand maybe that will give you some ideas how to achieve the goals\nbetter. 1.5 years ago I didn't know how to use gdb properly, and it\nwas much more important for me to start doing just something, that's\nwhy I used debug prints. The meaning is the same anyway.\n\nThe most important advice that I can give you: think about whole\nprocess, then try to design your steps so that they could be as small\nas possible. I mean, it's not a good idea to make big patches (more\nthan 3-5 commits), especially at the beginning.\n\n[1] https://github.com/git/git/commits?author=telezhnaya\n"},{"id":"372885","messageId":"CAMknYENiA8sEm0vPk1nn45i_VomjeFpjy0bxPLixEa_Mg1eazw@mail.gmail.com","threadId":"50819","inReplyTo":"20190331184930.GV32487@hank.intra.tgummerer.com","subject":"Re: [GSoC] Unify ref-filter formats with other --pretty formats","fromName":"Kapil Jain","fromEmail":"jkapil.cs@gmail.com","sentAt":"2019-04-01T12:58:46Z","receivedAt":"2019-04-01T12:59:00Z","isPatch":false,"sender":{"key":"jkapil.cs@gmail.com","avatar":null},"body":"On Mon, Apr 1, 2019 at 12:19 AM Thomas Gummerer <t.gummerer@gmail.com> wrote:\n>\n> If you look at what userformat_find_requirements() does, calls\n> strbuf_expand(), which in turn calls userformat_want_item(), which\n> fills the 'userformat_want' struct based on the strbuf that has been\n> passed.\n>\n> Now if we look at the caller of userformat_find_requirements(), which\n> is cmd_log_init_finish(), you can see where 'w.notes' and 'w.source'\n> is used.\n>\n\ni actually got to userformat_find_requirements() by tracing from\ncmd_log() itself. although i won't say i read the\ncmd_log_init_finish() line by line.\nwill do.\n"}]}