scripts icon indicating copy to clipboard operation
scripts copied to clipboard

script doesn't work with relative-path submodules

Open mind-bending-forks opened this issue 7 years ago • 2 comments

I wanted to setup a simple example with sub-modules to check/demonstrate a bug, but the script doesn't appear to work with relative paths for submodules:

# Initialise two empty repositories
git init a
git init b
# Create and commit something in b
cd ../b
touch c
git add c
git commit -m "Added empty c" c
# Create b as a submodule within a and commit
cd ../a
git submodule add ../b b
git commit -m "Added b submodule" .gitmodules
# Try to rewrite b ...  
git-submodule-rewrite b

Get...

dirname: missing operand
Try 'dirname --help' for more information.
../git-submodule-rewrite: line 73: $2: unbound variable
Error: Could not determine the remote origin for this superproject: 
Usage: ../git-submodule-rewrite <submodule-name> [<submodule-branch>]
Merge a single branch of <submodule-name> into a repo, retaining file history.
If provided then <submodule-branch> will be merged, otherwise master.

options:
  -h, --help                Print this message
  -v, --verbose             Display verbose output

mind-bending-forks avatar Sep 25 '18 21:09 mind-bending-forks

I'd recommend manually updating the .gitmodules with full paths, or submitting a PR. Hopefully you still get some mileage out of the script.

jeremysears avatar Sep 25 '18 22:09 jeremysears

Unfortunately, it doesn't work for me with full paths, either. I have a local repo with local submodules, so the git config check for remote.origin.url cannot provide a URL :) . Ubuntu 18.04.2, bash 4.4.20, git 2.17.1.

cxw42 avatar Sep 09 '19 18:09 cxw42