../jeremysears/scripts/bin/git-submodule-rewrite -v hw-verify
This script will convert your "hw-verify" git submodule into
a simple subdirectory in the parent repository while retaining all
contents, file history and its own submodules.
The script will:
* delete the hw-verify submodule configuration from .gitmodules and
.git/config and commit it.
* rewrite the entire history of the hw-verify submodule so that all
paths are prefixed by hw-verify.
This ensures that git log will correctly follow the original file
history.
* merge the submodule into its parent repository and commit it.
* reinstate any of the submodule's own submodules as part of the parent
repository
NOTE: This script might completely garble your repository, so PLEASE apply
this only to a fresh clone of the repository where it does not matter if
the repo is destroyed. It would be wise to keep a backup clone of your
repository, so that you can reconstitute it if need be. You have been
warned. Use at your own risk.
Do you want to proceed? (y/n) y
+ git config -f .gitmodules --remove-section submodule.hw-verify
+ git config -f .git/config --get submodule.hw-verify.url
https://github.com/somecompany/hw-verify.git
+ git config -f .git/config --remove-section submodule.hw-verify
+ rm -rf hw-verify
+ git add -A .
+ git commit -m 'Remove submodule hw-verify'
[master 307e0e9] Remove submodule hw-verify
2 files changed, 4 deletions(-)
delete mode 160000 hw-verify
+ rm -rf .git/modules/hw-verify
++ mktemp -d -t submodule-rewrite-XXXXXX
+ local tmpdir=/tmp/submodule-rewrite-vD5x6o
+ git clone -b master https://github.com/somecompany/hw-verify.git /tmp/submodule-rewrite-vD5x6o
Cloning into '/tmp/submodule-rewrite-vD5x6o'...
remote: Counting objects: 123, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 123 (delta 69), reused 123 (delta 69), pack-reused 0
Receiving objects: 100% (123/123), 38.62 KiB | 0 bytes/s, done.
Resolving deltas: 100% (69/69), done.
Checking connectivity... done.
+ pushd /tmp/submodule-rewrite-vD5x6o
/tmp/submodule-rewrite-vD5x6o ~/projects/m5
++ printf '\t'
+ local 'tab= '
+ local 'filter=git ls-files -s | sed "s: : hw-verify/:" | GIT_INDEX_FILE=${GIT_INDEX_FILE}.new git update-index --index-info && mv ${GIT_INDEX_FILE}.new ${GIT_INDEX_FILE} || true'
+ git filter-branch --index-filter 'git ls-files -s | sed "s: : hw-verify/:" | GIT_INDEX_FILE=${GIT_INDEX_FILE}.new git update-index --index-info && mv ${GIT_INDEX_FILE}.new ${GIT_INDEX_FILE} || true' HEAD
Rewrite 902d922429ca56430397428f4d539f27499f363f (16/16)
Ref 'refs/heads/master' was rewritten
+ popd
~/projects/m5
+ git remote add hw-verify /tmp/submodule-rewrite-vD5x6o
+ git fetch hw-verify
warning: no common commits
remote: Counting objects: 139, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 139 (delta 69), reused 107 (delta 69)
Receiving objects: 100% (139/139), 39.32 KiB | 0 bytes/s, done.
Resolving deltas: 100% (69/69), done.
From /tmp/submodule-rewrite-vD5x6o
* [new branch] master -> hw-verify/master
+ git_version_lte 2.8.4
+++ echo 2.8.4
+++ tr . '\n'
+++ head -n 4
++ printf %03d%03d%03d%03d 2 8 4
+ OP_VERSION=002008004000
++ git version
+ GIT_VERSION='git version 2.1.4'
+++ echo ' 2.1.4'
+++ tr . '\n'
+++ head -n 4
++ printf %03d%03d%03d%03d 2 1 4
+ GIT_VERSION=002001004000
+ echo -e '002001004000\n002008004000'
+ sort
+ head -n1
002001004000
+ '[' 002001004000 -le 002008004000 ']'
+ ALLOW_UNRELATED_HISTORIES=
+ git merge -s ours --no-commit hw-verify/master
Automatic merge went well; stopped before committing as requested
+ rm -rf tmpdir
+ git clone -b master https://github.com/somecompany/hw-verify.git hw-verify
Cloning into 'hw-verify'...
remote: Counting objects: 123, done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 123 (delta 69), reused 123 (delta 69), pack-reused 0
Receiving objects: 100% (123/123), 38.62 KiB | 0 bytes/s, done.
Resolving deltas: 100% (69/69), done.
Checking connectivity... done.
+ add_submod_cmds=
+ '[' -f hw-verify/.gitmodules ']'
++ git config -f hw-verify/.gitmodules --name-only --get-regexp path
++ sed -re 's/^submodule\.(.+)\.path$/\1/g'
error: unknown option `name-only'
usage: git config [options]
Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object
Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--get-urlmatch get value specific for the URL: section[.var] URL
--replace-all replace all matching variables: name value [value_regex]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color <slot> find the color configured: [default]
--get-colorbool <slot>
find the color setting: [stdout-is-tty]
Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)
Other
-z, --null terminate values with NUL byte
--includes respect include directives on lookup
+ sub_names=
# uname -a
Linux aspire-v15 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux
# cat /etc/debian_version
8.9
# git --version
git version 2.1.4
# apt-get upgrade git
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... git is already the newest version.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.