2

Trying to use the git sparse checkout in jenkins. But this thing doesn't seem to like the ways which i am trying use to get a sub-directory with space in the name.

E.g. i am trying to get the folder:

/foo/bar baz/folder/desired_folder

enter image description here

I have already tried like so with no luck:

"/foo/bar baz/folder/desired_folder"
/foo/bar\ baz/folder/desired_folder

The same nature is seen while using the git bash to verify the sparse checkout. Is there a way to escape the space. Else i have to rename the folders and checkin again

OK999
  • 1,353
  • 2
  • 19
  • 39
  • `%20` worth to try as well. But I'm quite sure that GUI is not a friend of a developer. – 0andriy Mar 07 '17 at 21:33
  • Its not just on the GUI. The git-sparse option in git itself, doesn't respect the conventional escaping of spaces in the `.git/info/sparse-checkout` – OK999 Mar 07 '17 at 21:41
  • I see, only what I can suggest is not to use space in pathnames, less headache. – 0andriy Mar 07 '17 at 21:50
  • Which version of Jenkins and which version of the Git plugin are you using? – VonC Mar 08 '17 at 22:32
  • Jenkins ver. 1.625.18.5 (CloudBees Jenkins Operations Center 1.8), Git plugin 3.0.0.. Is from one of the 2 setup's that have failed. My local open sourced jenkins instance fails as well. Also the git client version, with which i tried the git-sparse manually by removing jenkins from the equation. git version 2.11.0.windows.3 – OK999 Mar 08 '17 at 23:22

1 Answers1

4

I just encountered this issue and here's what worked for me, in git version 2.10.2.windows.1.

Test repo that I created for this example: https://github.com/dixon/TestSparseCheckout

Following these excellent instructions, here's the echo command I used - I didn't escape anything, but I added an *:

$ echo "Folder With Spaces/*" >> .git/info/sparse-checkout

$ cat .git/info/sparse-checkout
Folder With Spaces/*

And then verification:

$ git pull origin master
From https://github.com/dixon/TestSparseCheckout
 * branch            master     -> FETCH_HEAD

$ ls
total 8.0K
drwxr-xr-x 1 dixon 0 Mar 21 14:21 ./
drwxr-xr-x 1 dixon 0 Mar 21 14:19 ../
drwxr-xr-x 1 dixon 0 Mar 21 14:21 .git/
drwxr-xr-x 1 dixon 0 Mar 21 14:21 'Folder With Spaces'/

$ ls Folder\ With\ Spaces/
total 1.0K
drwxr-xr-x 1 dixon  0 Mar 21 14:21 ./
drwxr-xr-x 1 dixon  0 Mar 21 14:21 ../
-rw-r--r-- 1 dixon 10 Mar 21 14:21 'Should Checkout.txt'

Looks like it worked; the DoNotCheckout wasn't downloaded.

Community
  • 1
  • 1
Jarrod Dixon
  • 15,727
  • 9
  • 60
  • 72