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

Re: [PATCH] Make "git reset" a builtin. (incomplete)

From
Nicolas Pitre <nico@cam.org>
Date
Aug 23, 2007, 01:15 UTC
Message-ID
<alpine.LFD.0.999.0708222033040.16727@xanadu.home>
In-Reply-To
<alpine.LFD.0.999.0708221149440.30176@woody.linux-foundation.org>
[ I'm branching off from here and not from later posts on purpose ... ]
On Wed, 22 Aug 2007, Linus Torvalds wrote:
Show 8 quoted lines
> "git reset" is a command, not a scripting language. We can still script 
> git as much as we want, but the fewer dependencies we have on anything 
> external, the better off we are.
> 
> I don't understand why people consider scripting languages (whether shell, 
> perl, or anything else) "better" than C if there is an alternative. Once 
> the C work has been done (and if you require C _anyway_ for other reasons, 
> like git does), doing it in C is simply superior.

Absolutely no argument with that. Considering that "git reset" is a command, the language used to implement it is just that: an _implementation_ "detail". Especially if the C conversion has already been done.

> We ended up writing our own versions (or merging other peoples code) for 
> things like appying patches, generating diffs, three-way merging etc, 
> because not having external dependencies is *so* much more maintainable 
> and portable that it's not even funny.

Indeed. And this is the very same reason why Git should _also_ acquire a script interpreter of its own if we want to continue bragging about Git's easy scriptability.

> I'd love for every single shell-script in git core to be written in C, so 
> that we can drop the dependency on shell *entirely*.
What about the test suite?
Show 5 quoted lines
> I also dispute your "easy to do". Quite often, shell (or any scripting 
> language) is actually much *more* complicated than C. Yes, the C code may 
> be more lines (in this case, the shell script is 106 lines, and the C code 
> was 216 lines), but from a maintenance standpoint, C has had *much* fewer 
> problems than the shell script stuff has ever had!

Let's not talk strictly about this very case. Like we agreed above, the C conversion has been done so there is no downside really not to move on with the C version. Same for other core commands if/when they get converted.

That would still be nice, though, if we could have a unified scripting language for Git, that didn't have any nasty external dependency either. If only so Git could be self sufficient on any platform it is ported to for its test suite, and also for extra functionality that users would end up sharing across the whole user base and not only on platform where bash comes installed by default.

And there might be some cases where using that same scripting language for permanently implementing actual command could simply make sense once it can be safely depended upon.

Show 10 quoted lines
> So scripting languages are often good for *prototyping*, and a lot of 
> people like scripting languages for that reason. But once something is 
> already prototyped, and if somebody then rewrites it in C, all the 
> advantages of a scripting language have already disappeared!
> 
> So yes, we could just make the shell/etc from busybox _be_ the scripting 
> language, but the fact is, that is *more* C code than just making the 
> commands C code in the first place, and while a lot of the effort is 
> already done for us, "busybox under windows" is actually likely to be more 
> of a maintenance problem than "native git commands under windows" are.

Possibly. Again that depends how much we need from it. We don't need _that_ much from a shell and the bad portability issues can certainly be avoided altogether simply by ripping out problematic functionality. Such shell doesn't even have to be POSIX compliant or whatever.

> So if we have the choice, and somebody has written a git command in native 
> C code, I think we should *always* take it. Just because it means that 
> _eventually_ we can drop shell entirely, even if it would be a git 
> internal busybox shell.

It could be taken the other way around too: If we have the choice, and somebody has ported a subset of busybox to Windows tailored for Git plumbing usage, then we _could_ stop worrying so much about shell portability right there and redirect our efforts toward other things.

Nicolas
Previous: Wincent ColaiutaNext: Jon Smirl
Message 19 of 49 in “Make "git reset" a builtin. (incomplete)”
  1. Make "git reset" a builtin. (incomplete)Carlos Rica, Aug 22, 2007
  2. David KastrupAug 22, 2007
  3. Andreas EricssonAug 22, 2007
  4. David KastrupAug 22, 2007
  5. Mike HommeyAug 22, 2007
  6. Chris ShoemakerAug 22, 2007
  7. David KastrupAug 22, 2007
  8. Nicolas PitreAug 22, 2007
  9. Johannes SchindelinAug 22, 2007
  10. David KastrupAug 22, 2007
  11. Linus TorvaldsAug 22, 2007
  12. David KastrupAug 22, 2007
  13. Linus TorvaldsAug 22, 2007
  14. David KastrupAug 22, 2007
  15. Linus TorvaldsAug 22, 2007
  16. David KastrupAug 22, 2007
  17. Linus TorvaldsAug 23, 2007
  18. Wincent ColaiutaAug 23, 2007
  19. Nicolas PitreAug 23, 2007
  20. Jon SmirlAug 23, 2007
  21. Linus TorvaldsAug 23, 2007
  22. Junio C HamanoAug 23, 2007
  23. Johannes SchindelinAug 23, 2007
  24. Reece DunnAug 22, 2007
  25. Johannes SchindelinAug 23, 2007
  26. Theodore TsoAug 23, 2007
  27. Johannes SchindelinAug 23, 2007
  28. David TweedAug 23, 2007
  29. Theodore TsoAug 23, 2007
  30. Johannes SchindelinAug 23, 2007
  31. Jon SmirlAug 23, 2007
  32. Reece DunnAug 23, 2007
  33. Alex RiesenAug 23, 2007
  34. David KastrupAug 23, 2007
  35. Alex RiesenAug 23, 2007
  36. David KastrupAug 23, 2007
  37. Nicolas PitreAug 22, 2007
  38. Johannes SchindelinAug 23, 2007
  39. Nicolas PitreAug 23, 2007
  40. Reece DunnAug 22, 2007
  41. Johannes SchindelinAug 23, 2007
  42. Robin RosenbergAug 23, 2007
  43. Nguyen Thai Ngoc DuyAug 23, 2007
  44. Matthieu MoyAug 22, 2007
  45. David KastrupAug 22, 2007
  46. Andy ParkinsAug 22, 2007
  47. Johannes SixtAug 22, 2007
  48. Alex RiesenAug 22, 2007
  49. Johannes SchindelinAug 23, 2007

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.