summary refs log tree commit diff
path: root/pkgs/build-support/fetchgit/builder.sh
blob: 794b690341e3433e331a2495e1cf57bd78e20a60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
source $stdenv/setup

header "exporting $url (rev $rev) into $out"

git clone "$url" $out
if test -n "$rev"; then
  cd $out

  # Track all remote branches so that revisions like
  # `t/foo@{2010-05-12}' are correctly resolved.  Failing to do that,
  # Git bails out with an "invalid reference" error.
  for branch in $(git branch -rl | grep -v ' origin/master$')
  do
    git branch --track "$(echo $branch | sed -es,origin/,,g)" "$branch"
  done

  git checkout "$rev" --
fi

if test -z "$leaveDotGit"; then
    find $out -name .git\* | xargs rm -rf
fi

stopNest