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

Re: [PATCH v6] Add new git-related helper to contrib

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 23, 2013, 04:07 UTC
Message-ID
<CAMP44s37a0_wVVef+QVnLNvc8Uos_XpCZAtpX0RmQyMcuJHUHw@mail.gmail.com>
In-Reply-To
<7vvc6ah81g.fsf@alter.siamese.dyndns.org>
On Wed, May 22, 2013 at 7:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>>> IIRC, git-gui runs two blames, one without any -C and one with (I do
>>> not offhand recall how many -C it uses) to show both.
>>
>> 'git blame' is a very expensive operation, perhaps we should add
>> another option so users don't need to run two blames to find this.
>
> Yes, you could add a "struct origin *suspect_in_the_same_file" next
> to the current "struct origin *suspect" to the blame_entry in order
> to represent the origin you would get if you were to stop at a "move
> across files" event, and keep digging, when you are operating under
> "-C -C" or higher mode.
No, this is what I meant:
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1509,16 +1509,6 @@ static void found_guilty_entry(struct blame_entry *ent)
        if (ent->guilty)
                return;
        ent->guilty = 1;
-       if (incremental) {
-               struct origin *suspect = ent->suspect;
-
-               printf("%s %d %d %d\n",
-                      sha1_to_hex(suspect->commit->object.sha1),
-                      ent->s_lno + 1, ent->lno + 1, ent->num_lines);
-               emit_one_suspect_detail(suspect, 0);
-               write_filename_info(suspect->path);
-               maybe_flush_or_die(stdout, "stdout");
-       }
 }

 /*
@@ -1536,12 +1526,24 @@ static void assign_blame(struct scoreboard *sb, int opt)
                struct origin *suspect = NULL;

                /* find one suspect to break down */
-               for (ent = sb->ent; !suspect && ent; ent = ent->next)
-                       if (!ent->guilty)
+               for (ent = sb->ent; ent; ent = ent->next)
+                       if (!ent->guilty) {
                                suspect = ent->suspect;
+                               break;
+                       }
+
                if (!suspect)
                        return; /* all done */

+               if (incremental &&
!is_null_sha1(suspect->commit->object.sha1)) {
+                       printf("%s %d %d %d\n",
+
sha1_to_hex(suspect->commit->object.sha1),
+                                       ent->s_lno + 1, ent->lno + 1,
ent->num_lines);
+                       emit_one_suspect_detail(suspect, 0);
+                       write_filename_info(suspect->path);
+                       maybe_flush_or_die(stdout, "stdout");
+               }
+
                /*
                 * We will use this suspect later in the loop,
                 * so hold onto it in the meantime.
-- 
Felipe Contreras
Previous: Junio C HamanoNext: Felipe Contreras
Message 13 of 27 in “Add new git-related helper to contrib”
  1. Add new git-related helper to contribFelipe Contreras, May 19, 2013
  2. Eric SunshineMay 20, 2013
  3. Junio C HamanoMay 22, 2013
  4. Junio C HamanoMay 22, 2013
  5. Felipe ContrerasMay 22, 2013
  6. Junio C HamanoMay 22, 2013
  7. Felipe ContrerasMay 22, 2013
  8. Junio C HamanoMay 22, 2013
  9. Junio C HamanoMay 22, 2013
  10. Junio C HamanoMay 22, 2013
  11. Felipe ContrerasMay 22, 2013
  12. Junio C HamanoMay 23, 2013
  13. Felipe ContrerasMay 23, 2013
  14. Felipe ContrerasMay 23, 2013
  15. Junio C HamanoMay 23, 2013
  16. Junio C HamanoMay 23, 2013
  17. Felipe ContrerasMay 23, 2013
  18. Junio C HamanoMay 23, 2013
  19. Felipe ContrerasMay 23, 2013
  20. Junio C HamanoMay 23, 2013
  21. Felipe ContrerasMay 23, 2013
  22. Junio C HamanoMay 23, 2013
  23. Felipe ContrerasMay 24, 2013
  24. Felipe ContrerasMay 23, 2013
  25. Felipe ContrerasMay 23, 2013
  26. Junio C HamanoMay 23, 2013
  27. Felipe ContrerasMay 22, 2013

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.