UFO:Alien Invasion

Development => Newbie Coding => Topic started by: ShipIt on October 30, 2015, 09:59:26 am

Title: Calling msysgit with parameters
Post by: ShipIt on October 30, 2015, 09:59:26 am
Still fiddling with my home project (which btw now really works, see pic), I would like to find a way renaming/moving project files out of a Python script in Windows. Right now I have to manually start msysgit.bat, change the project by typing ufoai, then type e.g. git mv /e/buildUFOAI/ufoai/base/maps/city_industry.map /e/buildUFOAI/ufoai/base/maps/industrial/ind_city_industry.map. Afterwards I have to alter this line for every single file, which is time consuming and boring.

I already managed to do something similar by calling the win cmd and using ufo2map for compiling maps and stuff. I have all the basics in place, but cannot find out how to do the last line. If I am not mistaken, msysgit.bat will not take nor pass any parameters, so how to?
Title: Re: Calling msysgit with parameters
Post by: anonymissimus on October 30, 2015, 03:10:58 pm
Where does your msysgit.bat come from and what is its content (code) ?
I assume it opens up a bash-like MinGw shell under windows with git commands available. For calling a command such as  git mv /e/buildUFOAI/ufoai/base/maps/city_industry.map /e/buildUFOAI/ufoai/base/maps/industrial/ind_city_industry.map from a cmd command window, or a batch script, or a python script, you would need to have msysgit installed with git command known to the system via environment variables. Or alternatively, use a full path to git.exe.
e.g. something like (in batch)
cd C:\ufoai //with ufoai being the project root, contains .git folder
C:\Program files\Git\bin\git.exe mv base/maps/city_industry.map base/maps/industrial/ind_city_industry.map

I'm pretty sure that this would about work on my windows system, where I have the former version of https://git-for-windows.github.io/ installed. And writing a script doing it shouldn't be very difficult. (I can't compile UFO:AI on windows but git operations work, on the same checkout.)

I just checked that it indeed works in cmd.exe:

F:\ufoai>i:\programs\Git\bin\git.exe mv TODO DONE

renames the file like it should.
Which surprises me, since normally I do git operations on windows also in a MinGw-like shell, which was added to the explorer's right-click menu by installing git.