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

Re: [PATCH] Use perl instead of tac

From
Brian Gernhardt <benji@silverinsanity.com>
Date
Apr 28, 2008, 19:13 UTC
Message-ID
<04EB077D-CB35-4253-A9EA-2085890C3639@silverinsanity.com>
In-Reply-To
<slrng1bqhb.25r.joerg@alea.gnuu.de>
On Apr 28, 2008, at 11:15 AM, Jörg Sommer wrote:
Show 5 quoted lines
> Nothing. My intention was not the speed, but the dependency on Perl.  
> But
> your are right. Except from the point that my suggestion is broken,  
> it's
> *much* slower:
[snip]
> And what about something like this: 'tac || rev || perl …'
This would actually be spelled something like:

----- 8< ----- tac=""

tac < /dev/null > /dev/null 2>&1
if test $? != 127; then
    tac=tac
fi
if test -z "$tac"; then
    perl < /dev/null > /dev/null 2>&1
    if test $? != 127; then
       tac="perl -e 'print reverse <>'"
    fi
fi
if test -z "$tac"; then
    die "Couldn't find tac or perl."
fi

(subshell) | $tac | while loop ----- 8< -----

Ugly, no? Plus it adds a dependency on tac OR doesn't solve the perl dependency. I personally think using perl is better than this approach. Even if we're trying to reduce the perl dependency in core, it's there right now so this has zero impact now. The ideal solution is to re-write the loop so that it doesn't need to be reversed in the first place. We can use perl until that rewrite is done.

This loop-reverse-loop construct is _extremely_ ugly, and I'm having problems following it. None of what this function is doing is immediately obvious. It's a good candidate for a comment or two.

Looking over it, we should be able to do this with one loop over the list of commits, doing this for each of them:

if more than one parent
   other_parents=all but first, comma separated
   print merge command (without marks)
else
   print pick command
fi
if commit is tagged
   print tag command
fi

I also dislike the large lists this is carrying around in shell variables. If I'm reading it correctly, the tag list could be replaced by invocations of "git describe --exact-match". The mark list appears to be unavoidable, but significantly smaller than the tag list.

Now that I think about it, the generation of marks could be done by a second loop over the list. Notice what commits need to be marked in loop 1, then add the mark commands in loop 2. Both of these loops would function in the same direction, removing the need for either tac or perl.

~~ Brian
Previous: Brian GernhardtNext: Jörg Sommer
Message 19 of 30 in “Use of tac in git-rebase--interactive”
  1. Brian GernhardtApr 27, 2008
  2. Jeff KingApr 27, 2008
  3. Use perl instead of tacBrian Gernhardt, Apr 27, 2008
  4. rebase--interactive: Replace unportable 'tac' by a sed script.Johannes Sixt, Apr 28, 2008
  5. Junio C HamanoApr 28, 2008
  6. Paolo BonziniApr 28, 2008
  7. Jeff KingApr 28, 2008
  8. Andreas EricssonApr 28, 2008
  9. Jörg SommerApr 28, 2008
  10. Randal L. SchwartzApr 28, 2008
  11. David SymondsApr 28, 2008
  12. Paolo BonziniApr 28, 2008
  13. Brian GernhardtApr 28, 2008
  14. Johannes SchindelinApr 28, 2008
  15. Jörg SommerApr 28, 2008
  16. Avery PennarunApr 28, 2008
  17. Matthieu MoyApr 28, 2008
  18. Brian GernhardtApr 28, 2008
  19. Brian GernhardtApr 28, 2008
  20. Jörg SommerApr 30, 2008
  21. Jörg SommerApr 30, 2008
  22. Brian GernhardtApr 30, 2008
  23. Brian GernhardtApr 30, 2008
  24. Jörg SommerMay 4, 2008
  25. Brian GernhardtMay 6, 2008
  26. Johannes SchindelinApr 28, 2008
  27. Brian GernhardtApr 28, 2008
  28. Johannes SchindelinApr 28, 2008
  29. しらいしななこApr 27, 2008
  30. Junio C HamanoApr 30, 2008

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.