Skip to content

Commit 4a9b3bc

Browse files
committed
sdk: set and use src_dir for the commands working on source code
The `sdk` shell function intended to help working with the Git for Windows SDK is designed to make tasks easy such as building Git, or a Git for Windows installer. To that end, it auto-initializes worktrees when needed. But we repeat an awful lot near-hardcoded paths to the worktree. And the user will not necessarily know where the worktree is, either. So let's store the worktree's path in the src_dir variable (which is changed whenever we touch a different project). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 293b44a commit 4a9b3bc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

git-extra/git-sdk.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ sdk () {
7171
init-lazy)
7272
case "$2" in
7373
build-extra|git|MINGW-packages|MSYS2-packages)
74-
test -d /usr/src/"$2"/.git && return
75-
mkdir -p /usr/src/"$2" &&
76-
git -C /usr/src/"$2" init &&
77-
git -C /usr/src/"$2" config core.autocrlf false &&
78-
git -C /usr/src/"$2" remote add origin \
74+
src_dir=/usr/src/"$2"
75+
test -d "$src_dir"/.git && return
76+
mkdir -p "$src_dir" &&
77+
git -C "$src_dir" init &&
78+
git -C "$src_dir" config core.autocrlf false &&
79+
git -C "$src_dir" remote add origin \
7980
https://github.com/git-for-windows/"$2" ||
80-
sdk die "Could not initialize /usr/src/$2"
81+
sdk die "Could not initialize $src_dir"
8182
;;
8283
*)
8384
sdk die "Unhandled repository: $2" >&2
@@ -86,24 +87,24 @@ sdk () {
8687
;;
8788
init)
8889
sdk init-lazy "$2" &&
89-
git -C "/usr/src/$2" pull origin master
90+
git -C "$src_dir" pull origin master
9091
;;
9192
build)
9293
case "$2" in
9394
git)
9495
sdk init git &&
95-
make -C /usr/src/git -j$(nproc) DEVELOPER=1
96+
make -C "$src_dir" -j$(nproc) DEVELOPER=1
9697
;;
9798
installer)
9899
sdk init build-extra &&
99-
/usr/src/build-extra/installer/release.sh "${3:-0-test}"
100+
"$src_dir"/installer/release.sh "${3:-0-test}"
100101
;;
101102
git-and-installer)
102103
sdk build git &&
103-
make -C /usr/src/git strip install &&
104+
make -C "$src_dir" strip install &&
104105
pacman -Syyu git-extra &&
105106
sdk init build-extra &&
106-
/usr/src/build-extra/installer/release.sh "${3:-0-test}"
107+
"$src_dir"/installer/release.sh "${3:-0-test}"
107108
;;
108109
*)
109110
cat >&2 <<EOF

0 commit comments

Comments
 (0)