git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Rosen <jeremy.rosen@openwide.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: Paul Campbell <pcampbell@kemitix.net>, git@vger.kernel.org
Subject: Re: Questions/investigations on git-subtree and tags
Date: Tue, 12 Mar 2013 11:02:25 +0100 (CET)	[thread overview]
Message-ID: <2131964232.420820.1363082545306.JavaMail.root@openwide.fr> (raw)
In-Reply-To: <886271566.251606.1362763771332.JavaMail.root@openwide.fr>

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

Paul, I'm not quite sure where I should go from here...

should I send you a patch so you make it a V3 of your patch ? should I
send a patch superseeding yours ? 

I have also found a similar problem in git-subtree pull, which needs 
the same fix. 

in the mean time, attached is the current version of my changes

    Cordialement

    Jérémy Rosen

fight key loggers : write some perl using vim


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-git-subtree-make-sure-the-SHA-saved-as-ancestor-is-a.patch --]
[-- Type: text/x-patch; name=0001-git-subtree-make-sure-the-SHA-saved-as-ancestor-is-a.patch, Size: 1343 bytes --]

From 12490724ae955719694d825dff4fa9e0d2709c1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= <jeremy.rosen@openwide.fr>
Date: Tue, 12 Mar 2013 10:56:54 +0100
Subject: [PATCH 1/2] git-subtree: make sure the SHA saved as ancestor is a
 commit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When adding or merging the first parameter might not be a commit, it can also be a tag SHA.
This needs to be fixed by using the underlying commit or the ancestor finding code will croak at split time


Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
---
 contrib/subtree/git-subtree.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..8b9d114 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -531,7 +531,7 @@ cmd_add_repository()
 
 cmd_add_commit()
 {
-	revs=$(git rev-parse $default --revs-only "$@") || exit $?
+	revs=$(git rev-parse $default --revs-only "$1^{commit}") || exit $?
 	set -- $revs
 	rev="$1"
 	
@@ -655,7 +655,7 @@ cmd_split()
 
 cmd_merge()
 {
-	revs=$(git rev-parse $default --revs-only "$@") || exit $?
+	revs=$(git rev-parse $default --revs-only "$1^{commit}") || exit $?
 	ensure_clean
 	
 	set -- $revs
-- 
1.7.10.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-git-subtree-use-ls-remote-to-check-the-refspec-passe.patch --]
[-- Type: text/x-patch; name=0002-git-subtree-use-ls-remote-to-check-the-refspec-passe.patch, Size: 1628 bytes --]

From 05d1dd56217be59d69952a41d97e204cc7821948 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= <jeremy.rosen@openwide.fr>
Date: Tue, 12 Mar 2013 10:57:56 +0100
Subject: [PATCH 2/2] git-subtree: use ls-remote to check the refspec passed
 to pull and add
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

ls-remote is the correct way to check that a parameter is a valid fetchable target


Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
---
 contrib/subtree/git-subtree.sh |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8b9d114..61d4eab 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -503,13 +503,8 @@ 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"
+		git ls-remote --exit-code "$1" "$2" ||
+		die "'$2' is not a correct reference on '$1'"
 
 	    "cmd_add_repository" "$@"
 	else
@@ -700,6 +695,8 @@ cmd_merge()
 cmd_pull()
 {
 	ensure_clean
+	git ls-remote --exit-code "$1" "$2" ||
+		die "'$2' is not a correct reference on '$1'"
 	git fetch "$@" || exit $?
 	revs=FETCH_HEAD
 	set -- $revs
-- 
1.7.10.4


  reply	other threads:[~2013-03-12 10:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1492019317.191838.1362650820122.JavaMail.root@openwide.fr>
2013-03-07 10:25 ` Questions/investigations on git-subtree and tags Jeremy Rosen
2013-03-07 11:00   ` Paul Campbell
2013-03-07 11:05     ` Jeremy Rosen
2013-03-07 12:02       ` Paul Campbell
2013-03-07 12:50         ` Jeremy Rosen
2013-03-07 15:00           ` Paul Campbell
2013-03-07 15:15             ` Jeremy Rosen
2013-03-07 15:29               ` Paul Campbell
2013-03-07 16:09                 ` Jeremy Rosen
2013-03-08 16:29                   ` Jeremy Rosen
2013-03-08 17:23                     ` Junio C Hamano
2013-03-08 17:29                       ` Jeremy Rosen
2013-03-12 10:02                         ` Jeremy Rosen [this message]
2013-03-12 23:57                           ` Paul Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2131964232.420820.1363082545306.JavaMail.root@openwide.fr \
    --to=jeremy.rosen@openwide.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pcampbell@kemitix.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).