git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: GSoC draft proposal: Line-level history browser

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 23, 2010, 11:22 UTC
Message-ID
<201003231222.40745.jnareb@gmail.com>
In-Reply-To
<41f08ee11003230338y5cf70a13xa649e67071bc2a72@mail.gmail.com>
On Tue, 23 Mar 2010, Bo Yang wrote:
Please do not forget to include attribution line, like the one I have
added below:
 
> Jakub Narebski wrote:
Show 41 quoted lines
> > The problem is when you are asking about tracking a subset of lines
> > that appear in postimage of a patch.  For example if we ask for
> > history of
> >
> >                  strbuf_addstr(&buf, extra_hdr.items[i].string);
> >
> > line, should we track history of
> >
> >          for (i = 0; i < extra_hdr.nr; i++) {
> >
> > line which appears in relevant diff chunk?  If not, how we should
> > detect which line in preimage (if any) corresponds to given line in
> > postimage?
> 
> If I understand correctly, that is as following.
> 
> @@ -1008,29 +1000,29 @@ int cmd_format_patch(int argc, const char
> **argv, const char *prefix)
>                add_signoff = xmemdupz(committer, endpos - committer + 1);
>        }
> 
> -       for (i = 0; i < extra_hdr_nr; i++) {
> -              strbuf_addstr(&buf, extra_hdr[i]);
> +       for (i = 0; i < extra_hdr.nr; i++) {
> +              strbuf_addstr(&buf, extra_hdr.items[i].string);
>                strbuf_addch(&buf, '\n');
>        }
> 
> Here, the user only ask for tracking the strbuf_addstr line. And we
> find the above diff hunk. I think we can then find what the line would
> be in the preimage using @@ -1008,29 +1000,29 @@.  The strbuf_addstr
> is located at
> 1000(the postimage start line number)
> +3(the context number)
> +1(the number of lines '+' before this line) in the postimage,
> and we can calculate its line number in the preimage by the same way
> 1008
> +3
> +1(the number of lines with '-' before this line).
> 
> How do you think about this method?

This would work with the simplest case, but not in more complicated cases, like for example preimage and postimage with different size.

Take for example the following chunk (fragment):
diff --git a/run-command.c b/run-command.c
index 2feb493..3206d61 100644
--- a/run-command.c
+++ b/run-command.c
@@ -67,19 +67,21 @@ static int child_notifier = -1;
 
 static void notify_parent(void)
 {
-	write(child_notifier, "", 1);
+	ssize_t unused;
+	unused = write(child_notifier, "", 1);
 }
 
 static NORETURN void die_child(const char *err, va_list params)

If you follow ssize_t line, it is created.  If you follow line with
write, which is 2nd line in postimage, its previous version is 1st
line in preimage.


Another example would be reordering of lines, or reordering with
some change.
-- 
Jakub Narebski
Poland
Previous: Bo YangNext: Bo Yang
Message 25 of 54 in “GSoC draft proposal: Line-level history browser”
  1. Bo YangMar 20, 2010
  2. Johannes SchindelinMar 20, 2010
  3. Bo YangMar 20, 2010
  4. Junio C HamanoMar 20, 2010
  5. Bo YangMar 21, 2010
  6. Johannes SchindelinMar 20, 2010
  7. Bo YangMar 21, 2010
  8. Alex RiesenMar 20, 2010
  9. Junio C HamanoMar 20, 2010
  10. Bo YangMar 21, 2010
  11. A Large Angry SCMMar 20, 2010
  12. Bo YangMar 21, 2010
  13. A Large Angry SCMMar 21, 2010
  14. Bo YangMar 22, 2010
  15. Junio C HamanoMar 22, 2010
  16. Bo YangMar 22, 2010
  17. Junio C HamanoMar 22, 2010
  18. Bo YangMar 22, 2010
  19. Junio C HamanoMar 22, 2010
  20. Bo YangMar 22, 2010
  21. Jonathan NiederMar 22, 2010
  22. Bo YangMar 23, 2010
  23. Jakub NarebskiMar 23, 2010
  24. Bo YangMar 23, 2010
  25. Jakub NarebskiMar 23, 2010
  26. Bo YangMar 23, 2010
  27. Jakub NarebskiMar 23, 2010
  28. Bo YangMar 23, 2010
  29. Jonathan NiederMar 23, 2010
  30. A Large Angry SCMMar 23, 2010
  31. Bo YangMar 24, 2010
  32. Peter KjellerstedtMar 23, 2010
  33. Jonathan NiederMar 23, 2010
  34. Bo YangMar 24, 2010
  35. Jonathan NiederMar 24, 2010
  36. Alex RiesenMar 22, 2010
  37. Johannes SchindelinMar 22, 2010
  38. Bo YangMar 22, 2010
  39. Jakub NarebskiMar 22, 2010
  40. Johannes SchindelinMar 22, 2010
  41. Sverre RabbelierMar 22, 2010
  42. Johannes SchindelinMar 22, 2010
  43. Sverre RabbelierMar 22, 2010
  44. Johannes SchindelinMar 22, 2010
  45. Bo YangMar 23, 2010
  46. Bo YangMar 23, 2010
  47. Bo YangMar 29, 2010
  48. Thomas RastMar 29, 2010
  49. Bo YangMar 30, 2010
  50. Michael J GruberMar 30, 2010
  51. Michael J GruberMar 30, 2010
  52. Bo YangMar 30, 2010
  53. Jakub NarebskiMar 30, 2010
  54. Bo YangMar 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.