Switch jgit library to the EDL (3-clause BSD)
[egit/zawir.git] / org.spearce.jgit / src / org / spearce / jgit / transport / TagOpt.java
blob853b03bc559a926dbeac3015f4971aa93afe6fdd
1 /*
2 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
8 * conditions are met:
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
21 * written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org.spearce.jgit.transport;
40 /** Specification of annotated tag behavior during fetch. */
41 public enum TagOpt {
42 /**
43 * Automatically follow tags if we fetch the thing they point at.
44 * <p>
45 * This is the default behavior and tries to balance the benefit of having
46 * an annotated tag against the cost of possibly objects that are only on
47 * branches we care nothing about. Annotated tags are fetched only if we can
48 * prove that we already have (or will have when the fetch completes) the
49 * object the annotated tag peels (dereferences) to.
51 AUTO_FOLLOW(""),
53 /**
54 * Never fetch tags, even if we have the thing it points at.
55 * <p>
56 * This option must be requested by the user and always avoids fetching
57 * annotated tags. It is most useful if the location you are fetching from
58 * publishes annotated tags, but you are not interested in the tags and only
59 * want their branches.
61 NO_TAGS("--no-tags"),
63 /**
64 * Always fetch tags, even if we do not have the thing it points at.
65 * <p>
66 * Unlike {@link #AUTO_FOLLOW} the tag is always obtained. This may cause
67 * hundreds of megabytes of objects to be fetched if the receiving
68 * repository does not yet have the necessary dependencies.
70 FETCH_TAGS("--tags");
72 private final String option;
74 private TagOpt(final String o) {
75 option = o;
78 /**
79 * Get the command line/configuration file text for this value.
81 * @return text that appears in the configuration file to activate this.
83 public String option() {
84 return option;
87 /**
88 * Convert a command line/configuration file text into a value instance.
90 * @param o
91 * the configuration file text value.
92 * @return the option that matches the passed parameter.
94 public static TagOpt fromOption(final String o) {
95 if (o == null || o.length() == 0)
96 return AUTO_FOLLOW;
97 for (final TagOpt tagopt : values()) {
98 if (tagopt.option().equals(o))
99 return tagopt;
101 throw new IllegalArgumentException("Invald tag option: " + o);