* howto handle name clashes
@ 2012-03-23 13:06 Sven Strickroth
2012-03-23 17:12 ` Jeff King
2012-03-23 18:25 ` Junio C Hamano
0 siblings, 2 replies; 6+ messages in thread
From: Sven Strickroth @ 2012-03-23 13:06 UTC (permalink / raw)
To: git
Hi,
how to handle name clashes for branches and tags? Is there anything I
can add to the refspec to make the name unique?
E.g.
- for merging "git merge --no-ff refs/branches/test" works, but
generates a not so nice default merge message. ("merged commit
refs/branches/test" instead of "merged branch test")
- how to drop a remote tag/branch ("git push origin :test" does not work)
--
Best regards,
Sven Strickroth
ClamAV, a GPL anti-virus toolkit http://www.clamav.net
PGP key id F5A9D4C4 @ any key-server
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: howto handle name clashes
2012-03-23 13:06 howto handle name clashes Sven Strickroth
@ 2012-03-23 17:12 ` Jeff King
2012-03-23 17:43 ` Sven Strickroth
2012-03-24 0:19 ` Sven Strickroth
2012-03-23 18:25 ` Junio C Hamano
1 sibling, 2 replies; 6+ messages in thread
From: Jeff King @ 2012-03-23 17:12 UTC (permalink / raw)
To: Sven Strickroth; +Cc: git
On Fri, Mar 23, 2012 at 02:06:01PM +0100, Sven Strickroth wrote:
> how to handle name clashes for branches and tags? Is there anything I
> can add to the refspec to make the name unique?
You can always use a more fully-qualified name to disambiguate (e.g.,
"tags/foo", or "refs/tags/foo").
> - for merging "git merge --no-ff refs/branches/test" works, but
> generates a not so nice default merge message. ("merged commit
> refs/branches/test" instead of "merged branch test")
Did you mean "refs/heads/test"?
I would have thought we would full-qualify the refname first, and then
use that to determine the message. Doing a simple test, it looks like
"git merge foo" gets you "Merge branch 'foo'", but "git merge heads/foo"
will get you "Merge branch 'heads/foo'". We should be able to do better
in the latter case.
> - how to drop a remote tag/branch ("git push origin :test" does not work)
Does "git push origin :heads/foo" (or :tags/foo) not work?
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: howto handle name clashes
2012-03-23 17:12 ` Jeff King
@ 2012-03-23 17:43 ` Sven Strickroth
2012-03-23 18:29 ` Jeff King
2012-03-24 0:19 ` Sven Strickroth
1 sibling, 1 reply; 6+ messages in thread
From: Sven Strickroth @ 2012-03-23 17:43 UTC (permalink / raw)
To: git; +Cc: Jeff King
Am 23.03.2012 18:12 schrieb Jeff King:
>> - for merging "git merge --no-ff refs/branches/test" works, but
>> generates a not so nice default merge message. ("merged commit
>> refs/branches/test" instead of "merged branch test")
>
> Did you mean "refs/heads/test"?
yes. Your example was the correct one. Thanks for spotting my problem.
>> - how to drop a remote tag/branch ("git push origin :test" does not work)
>
> Does "git push origin :heads/foo" (or :tags/foo) not work?
seems to work. Thanks.
Really problematic is checkout:
"git checkout heads/foo" creates a detached HEAD (is this intended).
However, "git checkout heads/foo -B foo" can be used.
Is there a git command to find out if a name is ambiguous?
"git rev-parse foo" outputs "warning: refname 'test' is ambiguous.", but
the return code is zero.
--
Best regards,
Sven Strickroth
ClamAV, a GPL anti-virus toolkit http://www.clamav.net
PGP key id F5A9D4C4 @ any key-server
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: howto handle name clashes
2012-03-23 13:06 howto handle name clashes Sven Strickroth
2012-03-23 17:12 ` Jeff King
@ 2012-03-23 18:25 ` Junio C Hamano
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2012-03-23 18:25 UTC (permalink / raw)
To: Sven Strickroth; +Cc: git
Sven Strickroth <sven.strickroth@tu-clausthal.de> writes:
> how to handle name clashes for branches and tags? Is there anything I
> can add to the refspec to make the name unique?
>
> E.g.
> - for merging "git merge --no-ff refs/branches/test" works, but
> generates a not so nice default merge message. ("merged commit
> refs/branches/test" instead of "merged branch test")
That's the price you pay for naming different things the same and having
to disambiguate it.
> - how to drop a remote tag/branch ("git push origin :test" does not work)
"git push origin :refs/tags/test"
It is sad that some people teach new people shorthand without telling them
that what they are teaching are merely shorthand and cause confusion like
this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: howto handle name clashes
2012-03-23 17:43 ` Sven Strickroth
@ 2012-03-23 18:29 ` Jeff King
0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2012-03-23 18:29 UTC (permalink / raw)
To: Sven Strickroth; +Cc: git
On Fri, Mar 23, 2012 at 06:43:37PM +0100, Sven Strickroth wrote:
> Really problematic is checkout:
> "git checkout heads/foo" creates a detached HEAD (is this intended).
> However, "git checkout heads/foo -B foo" can be used.
Checkout is unlike regular ref lookup in that it prefers branches to
other forms (because it is fundamentally a branch operation). So "git
checkout foo" should always choose "refs/heads/foo". We do still seem to
give the ambiguity warning, though, which seems like overkill.
I think that generally people would want to get rid of ambiguous refs as
soon as they notice them, as they are a recipe for disaster. So the
warning being annoying has not been considered a huge problem.
> Is there a git command to find out if a name is ambiguous?
> "git rev-parse foo" outputs "warning: refname 'test' is ambiguous.", but
> the return code is zero.
I think you could do:
case "$(git show-ref --tags --heads $name | wc -l)" in
0) echo "$name does not exist" ;;
1) echo "$name is unambiguous" ;;
*) echo "$name is ambiguous" ;;
esac
You could also get a list of all ambiguous refs like this:
git for-each-ref --format='%(refname:short)' refs/heads refs/tags |
egrep '^(heads|tags)'
The ":short" modifier will shorten names unambiguously, so it ends up
leaving the "heads" and "tags" in for ambiguous names.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: howto handle name clashes
2012-03-23 17:12 ` Jeff King
2012-03-23 17:43 ` Sven Strickroth
@ 2012-03-24 0:19 ` Sven Strickroth
1 sibling, 0 replies; 6+ messages in thread
From: Sven Strickroth @ 2012-03-24 0:19 UTC (permalink / raw)
To: git; +Cc: Jeff King
Am 23.03.2012 18:12 schrieb Jeff King:
>> - how to drop a remote tag/branch ("git push origin :test" does not
>> work)
>
> Does "git push origin :heads/foo" (or :tags/foo) not work?
well, ":heads/foo" does not work. Imagine I want to drop a remote branch
which is ambiguous (e.g. a tag with same name exists) on the repository:
"git push origin :food"
gives me: "error: dst refspec food matches more than one."
However, deleting the remote tag (:tags/foo) works with your suggestion.
"git push origin :refs/remotes/origin/foo" showed success (and warning
"remote: warning: Allowing deletion of corrupt ref."), but did not work.
--
Best regards,
Sven Strickroth
ClamAV, a GPL anti-virus toolkit http://www.clamav.net
PGP key id F5A9D4C4 @ any key-server
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-24 0:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23 13:06 howto handle name clashes Sven Strickroth
2012-03-23 17:12 ` Jeff King
2012-03-23 17:43 ` Sven Strickroth
2012-03-23 18:29 ` Jeff King
2012-03-24 0:19 ` Sven Strickroth
2012-03-23 18:25 ` Junio C Hamano
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).