contrib: remove "git-new-workdir"

The "git-new-workdir" command has been introduced to make it possible to have a separate working directory in a different place. The command thus predates git-worktree(1), which is what people use nowadays to create any such working directory. As such, the script doesn't really have much of a reason to exist nowadays anymore. It also doesn't seem like the script is still in use: the last time it has received an update was in e32afab7b03 (git-new-workdir: don't fail if the target directory is empty, 2014-11-26), more than a decade ago. Remove it as well as the tests that depend on it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed May 12, 2025 at 11:20 UTC 15405cd325be6f51bea1115be6cc842d5b06f59d
5 files changed -184
contrib/workdir/.gitattributes deleted
-1
@@ -1 +0,0 @@
1 -/git-new-workdir eol=lf
contrib/workdir/git-new-workdir deleted
-105
@@ -1,105 +0,0 @@
1 -#!/bin/sh
2 -
3 -usage () {
4 - echo "usage:" $@
5 - exit 127
6 -}
7 -
8 -die () {
9 - echo $@
10 - exit 128
11 -}
12 -
13 -failed () {
14 - die "unable to create new workdir '$new_workdir'!"
15 -}
16 -
17 -if test $# -lt 2 || test $# -gt 3
18 -then
19 - usage "$0 <repository> <new_workdir> [<branch>]"
20 -fi
21 -
22 -orig_git=$1
23 -new_workdir=$2
24 -branch=$3
25 -
26 -# want to make sure that what is pointed to has a .git directory ...
27 -git_dir=$(cd "$orig_git" 2>/dev/null &&
28 - git rev-parse --git-dir 2>/dev/null) ||
29 - die "Not a git repository: \"$orig_git\""
30 -
31 -case "$git_dir" in
32 -.git)
33 - git_dir="$orig_git/.git"
34 - ;;
35 -.)
36 - git_dir=$orig_git
37 - ;;
38 -esac
39 -
40 -# don't link to a configured bare repository
41 -isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
42 -if test ztrue = "z$isbare"
43 -then
44 - die "\"$git_dir\" has core.bare set to true," \
45 - " remove from \"$git_dir/config\" to use $0"
46 -fi
47 -
48 -# don't link to a workdir
49 -if test -h "$git_dir/config"
50 -then
51 - die "\"$orig_git\" is a working directory only, please specify" \
52 - "a complete repository."
53 -fi
54 -
55 -# make sure the links in the workdir have full paths to the original repo
56 -git_dir=$(cd "$git_dir" && pwd) || exit 1
57 -
58 -# don't recreate a workdir over an existing directory, unless it's empty
59 -if test -d "$new_workdir"
60 -then
61 - if test $(ls -a1 "$new_workdir/." | wc -l) -ne 2
62 - then
63 - die "destination directory '$new_workdir' is not empty."
64 - fi
65 - cleandir="$new_workdir/.git"
66 -else
67 - cleandir="$new_workdir"
68 -fi
69 -
70 -mkdir -p "$new_workdir/.git" || failed
71 -cleandir=$(cd "$cleandir" && pwd) || failed
72 -
73 -cleanup () {
74 - rm -rf "$cleandir"
75 -}
76 -siglist="0 1 2 15"
77 -trap cleanup $siglist
78 -
79 -# create the links to the original repo. explicitly exclude index, HEAD and
80 -# logs/HEAD from the list since they are purely related to the current working
81 -# directory, and should not be shared.
82 -for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn reftable
83 -do
84 - # create a containing directory if needed
85 - case $x in
86 - */*)
87 - mkdir -p "$new_workdir/.git/${x%/*}"
88 - ;;
89 - esac
90 -
91 - ln -s "$git_dir/$x" "$new_workdir/.git/$x" || failed
92 -done
93 -
94 -# commands below this are run in the context of the new workdir
95 -cd "$new_workdir" || failed
96 -
97 -# copy the HEAD from the original repository as a default branch
98 -cp "$git_dir/HEAD" .git/HEAD || failed
99 -
100 -# the workdir is set up. if the checkout fails, the user can fix it.
101 -trap - $siglist
102 -
103 -# checkout the branch (either the same as HEAD from the original repository,
104 -# or the one that was asked for)
105 -git checkout -f $branch
t/meson.build
-1
@@ -178,7 +178,6 @@ integration_tests = [
178 't1015-read-index-unmerged.sh',
179 't1016-compatObjectFormat.sh',
180 't1020-subdirectory.sh',
181 - 't1021-rerere-in-workdir.sh',
181 't1022-read-tree-partial-clone.sh',
182 't1050-large.sh',
183 't1051-large-conversion.sh',
t/t1021-rerere-in-workdir.sh deleted
-58
@@ -1,58 +0,0 @@
1 -#!/bin/sh
2 -
3 -test_description='rerere run in a workdir'
4 -GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 -export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6 -
7 -. ./test-lib.sh
8 -
9 -test_expect_success SYMLINKS setup '
10 - git config rerere.enabled true &&
11 - >world &&
12 - git add world &&
13 - test_tick &&
14 - git commit -m initial &&
15 -
16 - echo hello >world &&
17 - test_tick &&
18 - git commit -a -m hello &&
19 -
20 - git checkout -b side HEAD^ &&
21 - echo goodbye >world &&
22 - test_tick &&
23 - git commit -a -m goodbye &&
24 -
25 - git checkout main
26 -'
27 -
28 -test_expect_success SYMLINKS 'rerere in workdir' '
29 - rm -rf .git/rr-cache &&
30 - "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . work &&
31 - (
32 - cd work &&
33 - test_must_fail git merge side &&
34 - git rerere status >actual &&
35 - echo world >expect &&
36 - test_cmp expect actual
37 - )
38 -'
39 -
40 -# This fails because we don't resolve relative symlink in mkdir_in_gitdir()
41 -# For the purpose of helping contrib/workdir/git-new-workdir users, we do not
42 -# have to support relative symlinks, but it might be nicer to make this work
43 -# with a relative symbolic link someday.
44 -test_expect_failure SYMLINKS 'rerere in workdir (relative)' '
45 - rm -rf .git/rr-cache &&
46 - "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . krow &&
47 - (
48 - cd krow &&
49 - rm -f .git/rr-cache &&
50 - ln -s ../.git/rr-cache .git/rr-cache &&
51 - test_must_fail git merge side &&
52 - git rerere status >actual &&
53 - echo world >expect &&
54 - test_cmp expect actual
55 - )
56 -'
57 -
58 -test_done
t/t3000-ls-files-others.sh
-19
@@ -73,25 +73,6 @@ test_expect_success 'ls-files --others handles non-submodule .git' '
73 test_cmp expected1 output
74 '
75
76 -test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
77 - git init super &&
78 - git init sub &&
79 - (
80 - cd sub &&
81 - >a &&
82 - git add a &&
83 - git commit -m sub &&
84 - git pack-refs --all
85 - ) &&
86 - (
87 - cd super &&
88 - "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" ../sub sub &&
89 - git ls-files --others --exclude-standard >../actual
90 - ) &&
91 - echo sub/ >expect &&
92 - test_cmp expect actual
93 -'
94 -
76 test_expect_success 'setup nested pathspec search' '
77 test_create_repo nested &&
78 (