Apply mulitple patches from a directory using msysgit - windows

When I run the following command to apply multiple patches located in /c/tmp/patches msysgit hangs:
git.exe am --3way --signoff --directory=/c/tmp/patches/
I am using version 1.7.8-preview20111206.
Am I doing something wrong or is this a known issue in msysgit?

I believe the --directory switch is for specifying the target directory to apply the patch relative to and is not for telling it a directory containing patch files. According to the am documentation it passes the --directory option to the apply command (see also apply --directory documentation).
On Windows 10 git apply --3way ./.patches/*.patch runs fine in Git Bash (applies multiple patch files).
However that does not in powershell, CMD or Git CMD - I get error: can't open patch './.patches/*.patch': No such file or directory even though dir ./.patches/*.patch correctly lists the files. Not sure why (would like to know).

Related

Add symlink file as file using Git on Windows

I have a big (more than 1000 files) VS C# project in git. I need to create a small demo project and use ten files from the big project. To create this new project, I added ten files with mklink (symlink) from the big project to the small. All changes in corresponding files in the big and small project are identical. Now I need to add the small project to a different (my own) git repo.
But symlink will not add in git :
(error: readlink("X.cs"): Function not implemented)
How to add the X.cs (symlink) file in git as a regular file?
I need all changes in X.cs (in big project) to be moved to X.cs (small project).
If adding symlinks to the index fails with error error: readlink("..."): Function not implemented, try to find this line in the local or global config:
[core]
symlinks = false
You need to set symlinks = true for a successful push. Default value (=true) if parameter does not exist or is not working correctly and it depends on the settings with which the repository was created.
Hardlinks do not work with GIT, as the file and hardlink are stored as separate files.
It works the same with git version 2.8 or above (I did not check versions less than 2.8)
The current answer(s) are out-of-date and require revision given recent changes.
The solutions given there isn't enough and isn't working.
There are still issues with the latest Git 2.12 on Windows (February 2017, 18 months after the OP's question)
In the context of working on what was called git-new-workdir in 2015 (the ability, form one clone, to have multiple working tree: this ended up being called git worktree), the Git developers were asking how to reference those worktrees from the main cloned repo.
Would they be using ln? or its Windows equivalent mklink?
This thread, at the time, highlighted the issues:
When running on Windows in MinGW, creating symbolic links via ln always failed.
Using mklink instead of ln is the recommended method of creating links on Windows
That might be true, but not ideal: "Git Bash Shell fails to create symbolic links" does mention:
For my setup, that is Git for Windows 2.11.0 installed on Windows 8.1 export MSYS=winsymlinks:nativestrict does the trick as explained here: git-for-windows/pull/156
It's important to launch the Git Bash shell as administrator as on Windows only administrators could create the symbolic links. So, in order to make tar -xf work and create the required symlinks:
Run Git Bash shell as an administrator
Run export MSYS=winsymlinks:nativestrict
Run tar
See also "Git Symlinks in Windows", where the setup now (Git for Windows 2.10+) include symlink support:
You need to specify that during the clone:
git clone -c core.symlinks=true <URL>
And your CMD session needs to be run as admin.
Needless to say imposing that prerequisite on Windows users is a no-go (Windows in enterprise generally come with limited or no privilege elevation)
Yet, PR 156 does represent some Windows support for symlink, released in Git For Windows 2.10 (Sept. 2016).
It is telling that git worktree ended up implementing the multiple working tree reference... by not relying on symbolic links and by making the borrowee and borrowers aware of each other.
When you are done with a linked working tree you can simply delete it.
The working tree's administrative files in the repository will eventually be removed automatically (see gc.pruneworktreesexpire in git config), or you can run git worktree prune in the main or any linked working tree to clean up any stale administrative files.
So no symbolic link there.
git has problems with individual file links but it has no problem with directory symbolic links(mklink /d ). Therefore move your image files to another directory in your big project and create directory link in your git repo to this directory.
See below for example.
P:\denemeler\gitdeneme1>mklink /d linkDirectory P:\puzzles
Created symbolic link : linkDirectory <<===>> P:\puzzles
P:\denemeler\gitdeneme1>git status
On branch master Untracked files:
(use "git add ..." to include in what will be committed)
linkDirectory/
nothing added to commit but untracked files present (use "git add" to
track)
P:\denemeler\gitdeneme1>git add linkDirectory
P:\denemeler\gitdeneme1>git status
On branch master Changes to be
committed: (use "git reset HEAD ..." to unstage)
new file: linkDirectory/Juggle Fest Question.txt
new file: linkDirectory/jugglefest.txt
new file: linkDirectory/triangle.txt
new file: linkDirectory/triangleQuestion.txt
P:\denemeler\gitdeneme1>git commit -m "new files"
[master 0c7d126] new
files 4 files changed, 14150 insertions(+) create mode 100644
linkDirectory/Juggle Fest Question.txt create mode 100644
linkDirectory/jugglefest.txt create mode 100644
linkDirectory/triangle.txt create mode 100644
linkDirectory/triangleQuestion.txt
P:\denemeler\gitdeneme1>echo "aa" > p:\puzzles\newFile.txt
P:\denemeler\gitdeneme1>git status
On branch master Untracked files:
(use "git add ..." to include in what will be committed)
linkDirectory/newFile.txt
nothing added to commit but untracked files present (use "git add" to
track)
Git does indeed have trouble with symlinks on Windows. However, I don't think you even need symlinks for your problem. A simple workaround is to write a small *.bat script to copy the files in question from one repository to another on demand. With symlink, you don't need to run a script, which saves you a few seconds, but you get a problem that you can accidentally change file in small repository and have unwanted modification in big repository.
Looks like all your simlinks located in one ntfs partition, if it is true, you can renew all simlinks to hardlinks, by some script with command, mklink /h...
Hardlinks friendly for any CVS.

SVN error while taking checkout using script

I am getting below error when taking checkout from svn using a script.
**[Test] $ /bin/sh -xe /tmp/hudson8576425899836211909.sh
+ sh /cvsrx/rxapp/build_dir/Jenkins_Scripts/test.sh
Could not load program svn:
Could not load module /opt/freeware/lib/libssl.so.
Dependent module /usr/lib/libcrypto.a(libcrypto.so.1.0.1) could not be loaded.
Member libcrypto.so.1.0.1 is not found in archive
Could not load module svn.
Dependent module /opt/freeware/lib/libssl.so could not be loaded.
Could not load module .
Build step 'Execute shell' marked build as failure
Finished: FAILURE**
In test.sh I have written just one line svn co /path to svn branch/
I am in middle of some test so please don't ask why am not using jenkins in build svn plugin.
here,I am able to take checkout on command prompt using svn co /path to svn branch/
But not if I write this command line in script and run in execute shell of jenkins.
Any help please ?
Am using jenkins on AIX 7 platform.
I had softlinks from /usr/bin/svn to /opt/freeware/bin/svn.SVN installed at /opt/freeware/bin/svn ..... By default when i do which svn its showing /usr/bin/svnBut When i deleted those softlinks and exported path,Jenkins didnt recognize SVN at all.And which svn command doesnot show any svn installed . PFB logs of jenkins :
`
/bin/sh -xe /tmp/hudson5607872610124977868.sh
+ export PATH=/opt/freeware/bin/svn/:/opt/freeware/bin/svnversion:/opt/freeware/bin/svn:/opt/freeware/bin/svnversion/:/usr/java5/lib:/opt/freeware/bin/svnversion/bin:/usr/local/bin:/usr/bin:/usr/X11R7/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/sbin:/
+ echo /opt/freeware/bin/svn/:/opt/freeware/bin/svnversion:/opt/freeware/bin/svn:/opt/freeware/bin/svnversion/:/usr/java5/lib:/opt/freeware/bin/svnversion/bin:/usr/local/bin:/usr/bin:/usr/X11R7/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/sbin:/opt/freeware/bin/svn/:/opt/freeware/bin/svnversion:/opt/freeware/bin/svn:/opt/freeware/bin/svnversion/:/usr/java5/lib:/opt/freeware/bin/svnversion/bin:/usr/local/bin:/usr/bin:/usr/X11R7/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/sbin
+ cd /usr/local/apps/Jenkins_new/scripts
+ ./test.sh
Could not load program /opt/freeware/bin/svn:
Could not load module /opt/freeware/lib/libssl.so.
Dependent module /usr/lib/libcrypto.a(libcrypto.so.1.0.1) could not be loaded.
Member libcrypto.so.1.0.1 is not found in archive
Could not load module svn.
Dependent module /opt/freeware/lib/libssl.so could not be loaded.
Could not load module .
./test.sh[3]: svn: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE`
ReInstalling Jenkins solved my problem !! It was due to corrupt plugin which happened due to server restart.
Thanks Everyone
I have not seen the exact command of svn you have used in test.sh, but would advice you to give full path of SVN in your calling line, eg /usr/bin/svn co .....
And if also possible make an entry in your test.sh for export PATH and export LD_LIBRARY_PATH setting them to values which are paths of the mentioned .so files
I see you're using Hudson/Jenkins. Hudson and Jenkins use SVNKit internally when checking stuff in and out of Subversion. This means that the command line svn client may not be installed on your system, or that it may have other problems.
It is also possible that there are multiple svn clients on your system. For example, you may have one under /usr/bin/svn and one under /usr/local/bin/svn. If Subversion is working from the command line, but not in the script, you may have a different $PATH setup when you're executing from the command line vs. the script from Hudson/Jenkins. You can add to your script (if it's BASH) the line type svn to see where your executing svn from. It may be different from what you are using from the command line. It may also be nice to print out $PATH as part of your script.
It would also be helpful to see the svn command that your script is executing, and tell us what you're trying to do. You can also add to your script the following lines:
PS4="\$LINE: "
set -xv
These lines will turn on shell script debugging, and help you locate where your script is having problems.
This will give you some clues as to what is going wrong in your script.
Reply
Thanks David. Here only 1 svn path exists (usr/bin/svn)but created as a softlink see -->cd /usr/bin/svn lrwxrwxrwx 1 root system 26 Jul 1 14:34 svn -> ../../opt/freeware/bin/svn. Also soflink of libs.so is created see --> lrwxrwxrwx 1 root system 15 Sep 13 18:15 libssl.so -> libssl.so.1.0.1 .......... Is it possible that softlink is creating these problems ?? Before requesting to remove these softlinks ,i need confirmation that these softlinks are creating problems.
Softlinking isn't unusual for Unix. For example, I have Ant, Grails, Maven, Subversion, and many other packages installed under /opt on my Mac. In order not to have to include each and every one of these in my path, I soft link all of the binaries for those programs under /usr/local/bin. About 80% of the programs under /usr/local/bin are merely soft links elsewhere.
Library soft links are also very common. This usually has to do with version numbering. When a program requests a library, it may or may not include the library's version number. So, you have libfoo-2.0.3.so on your drive. This is the actual version of foo. However, few programs will request that particular version. Instead, they may simply request they need Version #2 of foo or just say they need to link to foo.
To handle this, you will have libfoo2.0.3.so soft linked to libfoo-2.so for programs that specify they need version 2 of foo. Then, libfoo-2.so will be soft linked to libfoo.so. This way, libfoo will be called no matter what. If I install, libfoo2.0.4.so, I can change the link to libfoo-2.so to point to version 2.0.4 instead of version 2.0.3, and anything that depends upon Foo will be picking up the correct version.
Instead, let's look at the error message:
Could not load module /opt/freeware/lib/libssl.so.
   Dependent module /usr/lib/libcrypto.a(libcrypto.so.1.0.1) could not be loaded.
   Member libcrypto.so.1.0.1 is not found in archive
For some reason, it couldn't access the file /usr/lib/libcryto.a. Is this file on you machine? Is it in /usr/lib? If not, where is it located?
So, where did you get this version of Subversion from? Why is the link to the /opt/freeware/bin/ directory? Was this part of your system?
It could be that Subversion on your system is not complete and never did work. In Jenkins, the Subversion repository is accessed by the SVNKit Jarfile which is embedded inside Jenkins/Hudson itself, so it wouldn't really be a surprise to find that the Subversion binary didn't work.
Are you able to do anything with Subversion from the command line? If not, you may have to install a new version of Subversion from Perzl which is where CollabNet points to for an AIX version of Subversion. (It's at least up to date at version 1.8.4).
You may even want to change the soft link at /usr/bin/svn to point to the newer, working version of Subversion.

How can I install custom git commands (like git hooks) on Windows?

I am trying to use the git-hooks tool on Windows. But, I cannot figure out how to install the git-hooks.sh file such that I can type git hooks --install in Git Bash.
I tried putting it in C:\Program Files (x86)\Git\git, where a lot of other git-*.sh files seem to live. But no luck.
What's the secret?
Like the git-hooks installation instructions say, you need to "Add git-hooks to your PATH environment variable so 'git hooks' can be run" (or copy git-hooks to a directory that already is in your PATH). Neither the C:\Program Files (x86)\Git\git (does that directory really exist for you, I do not see it here) nor the C:\Program Files (x86)\Git\libexec\git-core directories are in your PATH by default. Although in fact any directory which is in your PATH would work, I'd recommend to use the directory where git.exe is located, usually C:\Program Files (x86)\Git\bin. Also be sure to keep the original git-hooks file name, do not rename the file to git-hooks.sh although it is a shell script.

Can't use gvim with pathogen under windows

I have pathogen setup and working fine under Linux, but when I try to use the some configuration with gvim73 under windows it doesn't work at all. I don't get any errors but it does nothing.
Here is my dotfiles repository up on git. I've checked this out to ~/vimfiles and I added the following to _vimrc:
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
I've tried just about everything including putting the autoload/pathogen.vim and bundles/ folders in the /vim73 directory under program files. Nothing.
Does anyone have some experience with this? I'm assuming there is something windows specific that needs to happen to make this work.
Edit: It is probably also worth noting I can run pathogen#runtime_append_all_bundles() even using tab completion so pathogen is being loaded, but my plugins are just not working.
I'm not sure it will help but here is my working configuration:
d:\soft\vim\vim73\ - gvim itself, i.e.
pathogen.vim is copied into the
d:\soft\vim\vim73\autoload\
d:\soft\vim\vimfiles\bundle - directory
for plugins
Corresponding lines from configuration file d:\soft\vim\_vimrc:
" Use pathogen to load plugins from bundle directory
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
Also I changed pathogen#helptags because original didn't work for my paths:
dir[0 : strlen($VIM)-1] !=# $VIM has been changed to stridx(dir, "bundle") != -1
It's an old question, but I had the same issue and solution as the OP, and it has a mildly annoying origin. I was using the following script to install everything on Windows (Vista+ and run as admin if you want the mklink part to work):
cd "%UserProfile%"
rmdir vimfiles /S /Q
git clone http://github.com/brymck/dotvim.git vimfiles
del _vimrc
mklink _vimrc vimfiles\vimrc
cd vimfiles
git submodule init
git submodule update
The above is just a Windows-y version of a Vimcast on syncing your Vim preferences with GitHub and is fairly straightforward, so I figure others may be doing something similar.
Anyway, your experience may differ (and this doesn't apply to Cygwin), but when I just copied and pasted this into the terminal, git submodule update got "eaten" while git submodule init was running. I didn't figure it out initially because this had never happened to me on Linux. In short, wait until everything else has completed before running git submodule update and you should be golden. (Also, FWIW, I'm using the current version of pathogen, which was last updated September 25, 2011.)
For me renaming the .vim folder into vimfiles solved the problem for Vim 7.4.
I had some kind of issue on Windows when I used the pathogen version provided by Vim.org
However, using github pathogen head, the issue was fixed.
I think the latest release from Vim.org is from January last year, and the latest commit on github is from November.
Specifically, I had this issue with after directory:
https://github.com/tpope/vim-pathogen/issues/closed#issue/12
I know this is a long time ago, but maybe it will help someone ... I had the same issue. It wouldn't give me any errors, but no plugins would be loaded. I then RTFM and noticed that he explicitly states at the top of this page that it should go in your vimrc not gvimrc. After I changed that I had no problems.

How to patch on Windows?

Given a (source) patch file, what's the easiest way to apply this patch on the source files under Windows?
A GUI tool where I can visually compare the unchanged-changed source lines would be great.
A good way to apply a patch file under Windows OS is using Git.
As I understood, Git is a version control solution like SVN.
Here is a guideline to apply a patch :
First of all, download the latest release of the Windows Git Edition here :
GIT
With the cmd prompt, change directory to the patch file and files to patch
Now you can use the following command line :
git apply --ignore-space-change --ignore-whitespace --whitespace=nowarn file.patch
Not that since Git 2.3.3 (March 2015), you can use git apply --unsafe-paths to use git apply outside a git repo.
See commit 5244a31 by Junio C Hamano (gitster)
"git apply" was not very careful about reading from, removing, updating and creating paths outside the working tree (under --index/--cached) or the current directory (when used as a replacement for GNU patch).
The documentation now includes:
--unsafe-paths:
By default, a patch that affects outside the working area (either a Git controlled working tree, or the current working directory when "git apply" is used as a replacement of GNU patch) is rejected as a mistake (or a mischief).
When git apply is used as a "better GNU patch", the user can pass the --unsafe-paths option to override this safety check.
This option has no effect when --index or --cached is in use.
So if you have git installed, git apply could help, even outside of any git repo.
Patch for Windows is what you're looking for.
WinMerge is awesome.
http://winmerge.org/

Resources