* git subtree error (just how do you expect me to merge 0 trees?)
@ 2012-10-18 23:04 Drew Crawford
2013-01-01 1:44 ` greened
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Drew Crawford @ 2012-10-18 23:04 UTC (permalink / raw)
To: git@vger.kernel.org
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).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2012-10-18 23:04 git subtree error (just how do you expect me to merge 0 trees?) Drew Crawford
@ 2013-01-01 1:44 ` greened
2013-01-01 2:09 ` greened
2013-01-01 2:39 ` greened
2 siblings, 0 replies; 7+ messages in thread
From: greened @ 2013-01-01 1:44 UTC (permalink / raw)
To: Drew Crawford; +Cc: git@vger.kernel.org
Drew Crawford <drew@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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2012-10-18 23:04 git subtree error (just how do you expect me to merge 0 trees?) Drew Crawford
2013-01-01 1:44 ` greened
@ 2013-01-01 2:09 ` greened
2013-01-01 3:16 ` Junio C Hamano
2013-01-01 2:39 ` greened
2 siblings, 1 reply; 7+ messages in thread
From: greened @ 2013-01-01 2:09 UTC (permalink / raw)
To: Drew Crawford; +Cc: git@vger.kernel.org
Drew Crawford <drew@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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2013-01-01 2:09 ` greened
@ 2013-01-01 3:16 ` Junio C Hamano
2013-01-01 4:04 ` greened
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2013-01-01 3:16 UTC (permalink / raw)
To: greened; +Cc: Drew Crawford, git@vger.kernel.org
greened@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2013-01-01 3:16 ` Junio C Hamano
@ 2013-01-01 4:04 ` greened
2013-01-01 5:54 ` Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: greened @ 2013-01-01 4:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Drew Crawford, git@vger.kernel.org
Junio C Hamano <gitster@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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2013-01-01 4:04 ` greened
@ 2013-01-01 5:54 ` Junio C Hamano
0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2013-01-01 5:54 UTC (permalink / raw)
To: greened; +Cc: Drew Crawford, git@vger.kernel.org
greened@obbligato.org writes:
> Junio C Hamano <gitster@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).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git subtree error (just how do you expect me to merge 0 trees?)
2012-10-18 23:04 git subtree error (just how do you expect me to merge 0 trees?) Drew Crawford
2013-01-01 1:44 ` greened
2013-01-01 2:09 ` greened
@ 2013-01-01 2:39 ` greened
2 siblings, 0 replies; 7+ messages in thread
From: greened @ 2013-01-01 2:39 UTC (permalink / raw)
To: Drew Crawford; +Cc: git@vger.kernel.org
Drew Crawford <drew@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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-01 5:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-18 23:04 git subtree error (just how do you expect me to merge 0 trees?) Drew Crawford
2013-01-01 1:44 ` greened
2013-01-01 2:09 ` greened
2013-01-01 3:16 ` Junio C Hamano
2013-01-01 4:04 ` greened
2013-01-01 5:54 ` Junio C Hamano
2013-01-01 2:39 ` greened
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).