Open fidian opened 10 years ago
git rev-parse
provides several switches to determine the cwd in relation to the entire repository. unfortunately I haven't seen a practical way to utilize its output when run from a repo inside a repo (submodule).
maybe the trick is to look above it for another .git
folder?
I don't want the cwd. I want the target of the executing script. If you use bash, the $0
variable would point to util/bin/setup_repository
instead of 3rd_party/git-started/util/bin/setup_repository
. There are tools out there to perform a readlink and resolve paths versus the current directory, but nothing elegant shows up for bash. Because I need this functionality immediately, it will happen well before other utility functions are sourced into the environment. I'm fine duplicating 10-15 lines of code to get the right answer but the libraries I have seen border on 200+ lines and that's an unacceptable amount of duplication for the various scripts.
If I have git-started as a submodule at
3rd_party/git-started
and I create a symlink fromutil/bin/setup_repository
to3rd_party/git-started/util/bin/setup_repository
, then the script misbehaves. I believe it thinks it is being executed from within the git-started repository, thus it thinks it is not a submodule.I am not sure if I can do anything about this behavior, but it is not desired and is thus a bug.