From 4922baa85708a319708f8318d83403eea3c6972a Mon Sep 17 00:00:00 2001 From: Matt McDonald Date: Thu, 13 Nov 2008 19:15:37 -0500 Subject: [PATCH] Make sure $root_dir does not have a trailing slash This adds support for using 'tg create' from within a subdirectory. Apparently, git doesn't seem a do a good job of normalizing paths. When topgit tries to add a new .topdeps file in a newly created branch, git bails out with: $ tg create new-branch tg: Automatically marking dependency on old-branch tg: Creating new-branch base from old-branch... Switched to a new branch "new-branch" (here, tg tries to do: git add ../../..//.topdeps) fatal: pathspec '/.topdeps' did not match any files Since $root_dir is used everywhere like: "$root_dir/.topdeps", this patch tries to make sure that $root_dir never has the trailing slash so it always produces safe paths. Signed-off-by: martin f. krafft --- tg.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tg.sh b/tg.sh index 7005f98..93e051e 100644 --- a/tg.sh +++ b/tg.sh @@ -241,6 +241,8 @@ do_help() set -e git_dir="$(git rev-parse --git-dir)" root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}" +# Make sure root_dir doesn't end with a trailing slash. +root_dir="${root_dir%/}" base_remote="$(git config topgit.remote 2>/dev/null)" || : tg="tg" # make sure merging the .top* files will always behave sanely -- 2.30.2