git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG/PATCH] contrib/subtree: allow addition of remote branch with name not locally present

From
Paul Campbell <pcampbell@kemitix.net>
Date
Feb 27, 2013, 23:51 UTC
Message-ID
<CALeLG_ndDWyPWRBQtKV4WswZUKRpNQzCAXmB0f0yoKGsAYMUig@mail.gmail.com>

cmd_add() attempts to check for the validity of refspec for the repository it is about to add as a subtree. It tries to do so before contacting the repository. If the refspec happens to exist locally (say 'master') then the test passes and the repo is fetched. If the refspec doesn't exist locally then the test fails and the remote repo is never contacted.

Removing the tests still works as the git fetch command fails with the perfectly accurate error:

  fatal: Couldn't find remote ref <refspec>
Signed-off-by: Paul Campbell <pcampbell@carnegiecollege.ac.uk>
---

I must confess to not understanding the comment preceding the rev-parse test. Given that it is against the rev-parse and not the cmd_add_repository call I'm assuming it can be removed.

 contrib/subtree/git-subtree.sh | 8 --------
 1 file changed, 8 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..9a38b18 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -503,14 +503,6 @@ cmd_add()

            "cmd_add_commit" "$@"
        elif [ $# -eq 2 ]; then
-           # Technically we could accept a refspec here but we're
-           # just going to turn around and add FETCH_HEAD under the
-           # specified directory.  Allowing a refspec might be
-           # misleading because we won't do anything with any other
-           # branches fetched via the refspec.
-           git rev-parse -q --verify "$2^{commit}" >/dev/null ||
-           die "'$2' does not refer to a commit"
-
            "cmd_add_repository" "$@"
        else
            say "error: parameters were '$@'"
--
1.8.2.rc1
-- 
Paul [W] Campbell
Next: Junio C Hamano
Message 1 of 3 in “contrib/subtree: allow addition of remote branch with name not locally present”
  1. contrib/subtree: allow addition of remote branch with name not locally presentPaul Campbell, Feb 27, 2013
  2. Junio C HamanoFeb 28, 2013
  3. Paul CampbellFeb 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.