aboutsummaryrefslogtreecommitdiff
path: root/scripts/git
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-10-31 14:24:50 +1000
committerteor <teor@torproject.org>2019-10-31 14:59:12 +1000
commit995618ec619739cb7c54e809d6d817be4e9ed2de (patch)
tree9e3b00ebd1906d420165a6accc48497a545c8d57 /scripts/git
parente046903f9360b0b0553a4e281fd1104eab4df93b (diff)
downloadtor-995618ec619739cb7c54e809d6d817be4e9ed2de.tar.gz
tor-995618ec619739cb7c54e809d6d817be4e9ed2de.zip
scripts/git: Make a master symlink in the worktree directory
When running git-setup-dirs.sh. Part of 32347.
Diffstat (limited to 'scripts/git')
-rwxr-xr-xscripts/git/git-setup-dirs.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/git/git-setup-dirs.sh b/scripts/git/git-setup-dirs.sh
index 495b22b261..a1e465818d 100755
--- a/scripts/git/git-setup-dirs.sh
+++ b/scripts/git/git-setup-dirs.sh
@@ -254,6 +254,25 @@ function make_directory
fi
}
+# Create a symlink from the first argument to the second argument
+# If the link already exists: fail if $USE_EXISTING is 0, otherwise skip.
+function make_symlink
+{
+ local cmd="ln -s '$1' '$2'"
+ printf " %s Creating symlink from %s to %s..." "$MARKER" "$1" "$2"
+ local check_cmd="[ ! -e '$2' ]"
+ msg=$( eval "$check_cmd" 2>&1 )
+ if validate_ret_skip $? "File already exists."; then
+ return
+ fi
+ if [ $DRY_RUN -eq 0 ]; then
+ msg=$( eval "$cmd" 2>&1 )
+ validate_ret $? "$msg"
+ else
+ printf "\\n %s\\n" "${IWTH}$cmd${CNRM}"
+ fi
+}
+
# Go into the directory or repository, even if $DRY_RUN is non-zero.
# If the directory does not exist, fail and log an error.
# Otherwise, silently succeed.
@@ -496,7 +515,12 @@ for ((i=0; i<COUNT; i++)); do
printf "%s Handling branch %s\\n" "$MARKER" "${BYEL}$branch${CNRM}"
# We cloned the repository, and master is the default branch
- if [ "$branch" != "master" ]; then
+ if [ "$branch" = "master" ]; then
+ if [ "$TOR_MASTER_NAME" != "master" ]; then
+ # Set up a master link in the worktree directory
+ make_symlink "$repo_path" "$GIT_PATH/$TOR_WKT_NAME/master"
+ fi
+ else
# git makes worktree directories if they don't exist
add_worktree "origin/$branch" "$repo_path"
fi