Skip to content
Open
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
13 changes: 2 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ sudo: false
# Want 'bash' but 'c' works:
language: c

branches:
only:
- master
- /^release\//

script:
- git checkout $(
git branch --contains HEAD
| cut -c3-
| grep -E '^(master$|release)'
| head -1
)
# NOTE: we have to make sure we're on a branch (rather than on a detached HEAD) because tests rely on it.
- git checkout -b travis-ci-dummy-branch-name
- GIT_COMMITTER_NAME=Bob
[email protected]
GIT_AUTHOR_NAME='Bob Blob'
Expand Down
7 changes: 7 additions & 0 deletions lib/git-subrepo
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ subrepo:clone() {
fi
o "Remove the old subdir."
RUN git rm -r -- "$subdir"

if [[ -z $override_branch ]]; then
o "Determine the upstream head branch."
get-upstream-head-branch
subrepo_branch="$output"
override_branch="$output" # Force update of the branch in .gitrepo
fi
else
assert-subdir-empty
if [[ -z $subrepo_branch ]]; then
Expand Down
9 changes: 8 additions & 1 deletion test/reclone.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ clone-foo-and-bar
test-exists \
"$OWNER/foo/bar/bard/"

# Test that reclone is not done if not needed.
export XYZ=1
is "$(
cd $OWNER/foo
Expand All @@ -24,19 +25,25 @@ is "$(
"Subrepo 'bar' is up to date." \
"No reclone if same commit"

# Test that reclone of a different ref works.
(
cd $OWNER/foo
git subrepo --quiet clone --force ../../../$UPSTREAM/bar --branch=refs/tags/A
)

is "$(git -C $OWNER/foo subrepo config bar branch)" \
"Subrepo 'bar' option 'branch' has value 'refs/tags/A'."
test-exists \
"!$OWNER/foo/bar/bard/"

# Test that reclone back to (implicit) master works.
(
cd $OWNER/foo
git subrepo --quiet clone -f ../../../$UPSTREAM/bar --branch=master
git subrepo --quiet clone -f ../../../$UPSTREAM/bar
)

is "$(git -C $OWNER/foo subrepo config bar branch)" \
"Subrepo 'bar' option 'branch' has value 'master'."
test-exists \
"$OWNER/foo/bar/bard/"

Expand Down