-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-sclone
More file actions
executable file
·45 lines (34 loc) · 995 Bytes
/
Copy pathgit-sclone
File metadata and controls
executable file
·45 lines (34 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# git "shared" but disconnected clone, useful for local throwaway repositories.
# Author: Noah Friedman <friedman@splode.com>
# Created: 2019-08-18
# Public domain
# $Id$
# Commentary:
# Removes upstream information to avoid accidental contamination of
# original while still making history available.
# Code:
: ${GITPROG:=git}
main()
{
arg=( "$@" )
dstdir=${arg[-1]}
unset arg[-1]
if [[ -d $dstdir ]]; then
srcdir=$dstdir
dstdir=${srcdir##*/}
dstdir=${dstdir%.git}
else
srcdir=${arg[-1]}
unset arg[-1]
fi
emptydir=${XDG_RUNTIME_DIR-${TMPDIR-/tmp}}/empty.$$
trap 'rmdir "$emptydir"' 0 1 2 3 15
(umask 077; mkdir -p "$emptydir")
$GITPROG clone --shared --template "$emptydir" "${arg[@]}" -- "$srcdir" "$dstdir"
$GITPROG -C "$dstdir" branch --unset-upstream
$GITPROG -C "$dstdir" config --unset remote.origin.url
$GITPROG -C "$dstdir" restore-commit-mtime
}
main "$@"
# eof