Skip to content

The "Push to create a project" command doesn't work when the path contains a space

Summary

The "Push to create a project" command doesn't work when the path contains a space.

Steps to reproduce

The command becomes visible when pressing the "show command" button on https://gitlab.com/projects/new

git push --set-upstream git@gitlab.com:jeroen-lanting/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)

Example Project

I local git repository located in the directory C:\Users\Firstname Lastname\git\MyProject,

What is the current bug behavior?

git rev-parse --show-toplevel | xargs basename

returns Firstname.

What is the expected correct behavior?

I would expect it to return MyProject.

Output of checks

This bug happens on GitLab.com

Possible fixes

Replacing the subcommand by

git rev-parse --show-toplevel | xargs -0 basename

will make it handle spaces in filenames correctly (see https://stackoverflow.com/questions/16758525/how-can-i-make-xargs-handle-filenames-that-contain-spaces )