Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread greened
Drew Crawford d...@drewcrawfordapps.com writes:

 I noticed today that if you leave off the branch name from git subtree like 
 so:

 $ git subtree add --prefix somewhere -m adding CDH as subtree path/to/repo
 warning: read-tree: emptying the index with no arguments is deprecated; use 
 --empty
 fatal: just how do you expect me to merge 0 trees?

 The error message is not particularly helpful (and seems to actually be in 
 read-subtree?)  The solution in my case was to add the branch name on the end 
 of the command.

 Ideally it would be better to emit an error-message from a script higher up 
 the calling chain that would be more descriptive about the problem (such as 
 suggesting no branch is specified).--

Good idea.  I'll code it up.

-David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread greened
Drew Crawford d...@drewcrawfordapps.com writes:

 Ideally it would be better to emit an error-message from a script
 higher up the calling chain that would be more descriptive about the
 problem (such as suggesting no branch is specified).--

I'm looking at implementing this but I need a bit of help from the git
experts.

git-subtree add accepts either a refspec or a path to a repository and a
refspec.  With one positional option, git-subtree add simply assumes
it's a refspec.  Is there an easy way to check whether a string is a
proper refspec?  Even better would be a way to check if a string is a
path to a git repository.

 -David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread greened
Drew Crawford d...@drewcrawfordapps.com writes:

 Ideally it would be better to emit an error-message from a script
 higher up the calling chain that would be more descriptive about the
 problem (such as suggesting no branch is specified).--

Ok, I used git rev-parse --verify and I have this working now.  Will
send to Junio in the batch with fixes from other folks.

Thanks for catching this!

 -David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread Junio C Hamano
gree...@obbligato.org writes:

 git-subtree add accepts either a refspec or a path to a repository and a
 refspec.

 With one positional option, git-subtree add simply assumes
 it's a refspec.  Is there an easy way to check whether a string is a
 proper refspec?  Even better would be a way to check if a string is a
 path to a git repository.

Do you literally mean a path to a repository in the above, or do
you mean a remote that is like what is accepted by 'git fetch'?
If you literary mean it is is a path to a git repository, you could
obviously use cd $there  git rev-parse --git-dir or something.

On the other hand, if you mean the command takes a remote and an
optional list of refspecs just like git fetch does, then I am not
sure it is a good design in the first place to allow refspecs
only, if only to keep the interface similar to git fetch (you
cannot omit remote and give refspecs, as you cannot interpret
refspecs without knowing in the context of which remote they are to
be interpreted).

I would imagine you could disambiguate and default to origin or
something when you guessed that remote was omitted if you really
wanted to, with a syntacitical heuristics, such as a refspec will
never have two colons in it, a URL tends to begin with a short
alphabet word, a colon and double-slash, etc.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread greened
Junio C Hamano gits...@pobox.com writes:

 With one positional option, git-subtree add simply assumes
 it's a refspec.  Is there an easy way to check whether a string is a
 proper refspec?  Even better would be a way to check if a string is a
 path to a git repository.

 Do you literally mean a path to a repository in the above, or do
 you mean a remote that is like what is accepted by 'git fetch'?

It's the latter as git-subtree calls git-fetch to do the work of
getting revisions.

 On the other hand, if you mean the command takes a remote and an
 optional list of refspecs just like git fetch does, then I am not
 sure it is a good design in the first place to allow refspecs
 only, if only to keep the interface similar to git fetch (you
 cannot omit remote and give refspecs, as you cannot interpret
 refspecs without knowing in the context of which remote they are to
 be interpreted).

If just a refspec is given, git-subtree does a rev-parse in the current
directory and that seems to work fine.  It's what I as a user would
expect to happen.

 I would imagine you could disambiguate and default to origin or
 something when you guessed that remote was omitted if you really
 wanted to, with a syntacitical heuristics, such as a refspec will
 never have two colons in it, a URL tends to begin with a short
 alphabet word, a colon and double-slash, etc.

Hmm...I haven't added code to verify the repository/remote argument if
given.  I suppose a rev-parse --verify would suffice?

-David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git subtree error (just how do you expect me to merge 0 trees?)

2012-12-31 Thread Junio C Hamano
gree...@obbligato.org writes:

 Junio C Hamano gits...@pobox.com writes:

 With one positional option, git-subtree add simply assumes
 it's a refspec.  Is there an easy way to check whether a string is a
 proper refspec?  Even better would be a way to check if a string is a
 path to a git repository.

 Do you literally mean a path to a repository in the above, or do
 you mean a remote that is like what is accepted by 'git fetch'?

 It's the latter as git-subtree calls git-fetch to do the work of
 getting revisions.

If that is the case, t should behave similar to 'git fetch' for
consistency.  If you want to name current repository, you can
simply give . as the repository parameter; this has long been
supported by 'git fetch' (as 'git pull . $branch' has been the way
to say 'git merge' for a long time).

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html