Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git clone & update helper scripts #993

Merged
merged 3 commits into from
Feb 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMake/cdat_modules_extra/git_clone.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh

cd @CMAKE_INSTALL_PREFIX@
"@GIT_EXECUTABLE@" clone --depth 1 -b @BRANCH@ @GIT_URL@ @GIT_TARGET@
cd "@CMAKE_INSTALL_PREFIX@"
"@GIT_EXECUTABLE@" clone --no-checkout --depth 1 -b @BRANCH@ @GIT_URL@ "@GIT_TARGET@"
cd "@GIT_TARGET@"
if [ "$("@GIT_EXECUTABLE@" cat-file -t @BRANCH@)" = tag ]; then
"@GIT_EXECUTABLE@" checkout @BRANCH@
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the else will checkout and result in a headless branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will checkout in "detached head" mode in any case, thus not changing local branches. Unfortunately "clone -b" will have already created a local branch if @BRANCH@ is a branch name. I don't know how to stop that.

"@GIT_EXECUTABLE@" checkout origin/@BRANCH@
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the local branch refs/heads/@BRANCH@ will still be created with upstream information (but not checked out); this is because of clone -b.

fi
13 changes: 6 additions & 7 deletions CMake/cdat_modules_extra/git_update.sh.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/sh
cd @SOURCE_DIR@
git fetch origin --prune
branch_name=$(git symbolic-ref HEAD | sed -e 's,.*\/\(.*\),\1,')
if [ $? = 0 -a "${branch_name}" != "@BRANCH@" ]; then
git checkout -f @BRANCH@
cd "@SOURCE_DIR@"
"@GIT_EXECUTABLE@" fetch origin --prune
if [ "$("@GIT_EXECUTABLE@" cat-file -t @BRANCH@)" = tag ]; then
"@GIT_EXECUTABLE@" checkout -f @BRANCH@
else
"@GIT_EXECUTABLE@" checkout -f origin/@BRANCH@
fi
git reset --hard origin/@BRANCH@