Recent

Author Topic: using git from code  (Read 1118 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 369
using git from code
« on: December 16, 2020, 11:09:56 am »
I'd like to be able to clone/manage git repositories from my code. Here's the git things I want to be able to do:

* clone a repo
* list the branches for the repo on the origin
* switch to a different branch

I looked at uGitForDelphi, but it's way out of date and doesn't match the instructions for how to use libgit2.dll

I tried to use TProcess with git from the command line on windows, either executing git directly, or cmd /c git, but TProcess didn't seem to know when git finished, or be able to get any output from it. I don't know if I was just doing something obviously wrong, or whether git is somehow special...

Has anyone done anything like this?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12107
  • FPC developer.
Re: using git from code
« Reply #1 on: December 16, 2020, 11:15:21 am »
I've done a lot of this with subversion to get mergable revisions and that just works with tprocess/runcommand. I don't see why git would be differnt.

Probably the first step is characterizing what the GIT commandline exactly is and if it is pipable on the cmdline.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4565
  • I like bugs.
Re: using git from code
« Reply #2 on: December 16, 2020, 11:35:32 am »
I tried to use TProcess with git from the command line on windows, either executing git directly, or cmd /c git, but TProcess didn't seem to know when git finished, or be able to get any output from it. I don't know if I was just doing something obviously wrong, or whether git is somehow special...
What is your OS? On Windows Git runs with a Unix emulator layer (Cygwin). Maybe it messes things up. Just a guess...
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 369
Re: using git from code
« Reply #3 on: December 16, 2020, 11:36:17 am »
yes windows (though OSX and linux also matter). So yes, I think it must be cygwin

MarkMLl

  • Hero Member
  • *****
  • Posts: 8317
Re: using git from code
« Reply #4 on: December 16, 2020, 11:41:02 am »
What is your OS? On Windows Git runs with a Unix emulator layer (Cygwin). Maybe it messes things up. Just a guess...

Didn't FPC use Cygwin for certain tasks at one point? If somebody could remember the details it might help rule out some scenarios.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12107
  • FPC developer.
Re: using git from code
« Reply #5 on: December 16, 2020, 11:45:52 am »
What is your OS? On Windows Git runs with a Unix emulator layer (Cygwin). Maybe it messes things up. Just a guess...

Didn't FPC use Cygwin for certain tasks at one point?

No. The textmode IDE did for its internal GDB before 2008-2010, but FPC never did.

But before this first a case that works with other cmdline binaries (like SVN) and not with GIT should be built.  e.g. there is no reason to use cmd /c with tprocess, that only confuses the picture.

 

TinyPortal © 2005-2018