GitProtocolConstants.java

  1. /*
  2.  * Copyright (C) 2008, 2013 Google Inc.
  3.  * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
  4.  * Copyright (C) 2008, 2022 Shawn O. Pearce <spearce@spearce.org> and others
  5.  *
  6.  * This program and the accompanying materials are made available under the
  7.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  8.  * https://www.eclipse.org/org/documents/edl-v10.php.
  9.  *
  10.  * SPDX-License-Identifier: BSD-3-Clause
  11.  */

  12. package org.eclipse.jgit.transport;

  13. /**
  14.  * Wire constants for the native Git protocol.
  15.  *
  16.  * @since 3.2
  17.  */
  18. public final class GitProtocolConstants {
  19.     /**
  20.      * Include tags if we are also including the referenced objects.
  21.      *
  22.      * @since 3.2
  23.      */
  24.     public static final String OPTION_INCLUDE_TAG = "include-tag"; //$NON-NLS-1$

  25.     /**
  26.      * Multi-ACK support for improved negotiation.
  27.      *
  28.      * @since 3.2
  29.      */
  30.     public static final String OPTION_MULTI_ACK = "multi_ack"; //$NON-NLS-1$

  31.     /**
  32.      * Multi-ACK detailed support for improved negotiation.
  33.      *
  34.      * @since 3.2
  35.      */
  36.     public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed"; //$NON-NLS-1$

  37.     /**
  38.      * The client supports packs with deltas but not their bases.
  39.      *
  40.      * @since 3.2
  41.      */
  42.     public static final String OPTION_THIN_PACK = "thin-pack"; //$NON-NLS-1$

  43.     /**
  44.      * The client supports using the side-band for progress messages.
  45.      *
  46.      * @since 3.2
  47.      */
  48.     public static final String OPTION_SIDE_BAND = "side-band"; //$NON-NLS-1$

  49.     /**
  50.      * The client supports using the 64K side-band for progress messages.
  51.      *
  52.      * @since 3.2
  53.      */
  54.     public static final String OPTION_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$

  55.     /**
  56.      * The client supports packs with OFS deltas.
  57.      *
  58.      * @since 3.2
  59.      */
  60.     public static final String OPTION_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$

  61.     /**
  62.      * The client supports shallow fetches.
  63.      *
  64.      * @since 3.2
  65.      */
  66.     public static final String OPTION_SHALLOW = "shallow"; //$NON-NLS-1$

  67.     /**
  68.      * The client wants the "deepen" command to be interpreted as relative to
  69.      * the client's shallow commits.
  70.      *
  71.      * @since 5.0
  72.      */
  73.     public static final String OPTION_DEEPEN_RELATIVE = "deepen-relative"; //$NON-NLS-1$

  74.     /**
  75.      * The client does not want progress messages and will ignore them.
  76.      *
  77.      * @since 3.2
  78.      */
  79.     public static final String OPTION_NO_PROGRESS = "no-progress"; //$NON-NLS-1$

  80.     /**
  81.      * The client supports receiving a pack before it has sent "done".
  82.      *
  83.      * @since 3.2
  84.      */
  85.     public static final String OPTION_NO_DONE = "no-done"; //$NON-NLS-1$

  86.     /**
  87.      * The client supports fetching objects at the tip of any ref, even if not
  88.      * advertised.
  89.      *
  90.      * @since 3.2
  91.      */
  92.     public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$

  93.     /**
  94.      * The client supports fetching objects that are reachable from a tip of a
  95.      * ref that is allowed to fetch.
  96.      *
  97.      * @since 4.1
  98.      */
  99.     public static final String OPTION_ALLOW_REACHABLE_SHA1_IN_WANT = "allow-reachable-sha1-in-want"; //$NON-NLS-1$

  100.     /**
  101.      * Symbolic reference support for better negotiation.
  102.      *
  103.      * @since 3.6
  104.      */
  105.     public static final String OPTION_SYMREF = "symref"; //$NON-NLS-1$

  106.     /**
  107.      * The client will send a push certificate.
  108.      *
  109.      * @since 4.0
  110.      */
  111.     public static final String OPTION_PUSH_CERT = "push-cert"; //$NON-NLS-1$

  112.     /**
  113.      * The client specified a filter expression.
  114.      *
  115.      * @since 5.0
  116.      */
  117.     public static final String OPTION_FILTER = "filter"; //$NON-NLS-1$

  118.     /**
  119.      * The client specified a want-ref expression.
  120.      *
  121.      * @since 5.1
  122.      */
  123.     public static final String OPTION_WANT_REF = "want-ref"; //$NON-NLS-1$

  124.     /**
  125.      * The client requested that the whole response be multiplexed, with
  126.      * each non-flush and non-delim pkt prefixed by a sideband designator.
  127.      *
  128.      * @since 5.5
  129.      */
  130.     public static final String OPTION_SIDEBAND_ALL = "sideband-all"; //$NON-NLS-1$

  131.     /**
  132.      * The server waits for client to send "done" before sending any packs back.
  133.      *
  134.      * @since 5.13
  135.      */
  136.     public static final String OPTION_WAIT_FOR_DONE = "wait-for-done"; //$NON-NLS-1$

  137.     /**
  138.      * The client supports atomic pushes. If this option is used, the server
  139.      * will update all refs within one atomic transaction.
  140.      *
  141.      * @since 3.6
  142.      */
  143.     public static final String CAPABILITY_ATOMIC = "atomic"; //$NON-NLS-1$

  144.     /**
  145.      * The client expects less noise, e.g. no progress.
  146.      *
  147.      * @since 4.0
  148.      */
  149.     public static final String CAPABILITY_QUIET = "quiet"; //$NON-NLS-1$

  150.     /**
  151.      * The client expects a status report after the server processes the pack.
  152.      *
  153.      * @since 3.2
  154.      */
  155.     public static final String CAPABILITY_REPORT_STATUS = "report-status"; //$NON-NLS-1$

  156.     /**
  157.      * The server supports deleting refs.
  158.      *
  159.      * @since 3.2
  160.      */
  161.     public static final String CAPABILITY_DELETE_REFS = "delete-refs"; //$NON-NLS-1$

  162.     /**
  163.      * The server supports packs with OFS deltas.
  164.      *
  165.      * @since 3.2
  166.      */
  167.     public static final String CAPABILITY_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$

  168.     /**
  169.      * The client supports using the 64K side-band for progress messages.
  170.      *
  171.      * @since 3.2
  172.      */
  173.     public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$

  174.     /**
  175.      * The server allows recording of push certificates.
  176.      *
  177.      * @since 4.0
  178.      */
  179.     public static final String CAPABILITY_PUSH_CERT = "push-cert"; //$NON-NLS-1$

  180.     /**
  181.      * Implementation name and version of the client or server.
  182.      *
  183.      * @since 4.0
  184.      */
  185.     public static final String OPTION_AGENT = "agent"; //$NON-NLS-1$

  186.     /**
  187.      * The server supports the receiving of push options.
  188.      *
  189.      * @since 4.5
  190.      */
  191.     public static final String CAPABILITY_PUSH_OPTIONS = "push-options"; //$NON-NLS-1$

  192.     /**
  193.      * The server supports the client specifying ref names.
  194.      *
  195.      * @since 5.1
  196.      */
  197.     public static final String CAPABILITY_REF_IN_WANT = "ref-in-want"; //$NON-NLS-1$

  198.     /**
  199.      * The server supports arbitrary options
  200.      *
  201.      * @since 5.2
  202.      */
  203.     public static final String CAPABILITY_SERVER_OPTION = "server-option"; //$NON-NLS-1$

  204.     /**
  205.      * The server supports the receiving of shallow options.
  206.      *
  207.      * @since 6.3
  208.      */
  209.     public static final String CAPABILITY_SHALLOW = "shallow"; //$NON-NLS-1$

  210.     /**
  211.      * Option for passing application-specific options to the server.
  212.      *
  213.      * @since 5.2
  214.      */
  215.     public static final String OPTION_SERVER_OPTION = "server-option"; //$NON-NLS-1$

  216.     /**
  217.      * Option for passing client session ID to the server.
  218.      *
  219.      * @since 6.4
  220.      */
  221.     public static final String OPTION_SESSION_ID = "session-id"; //$NON-NLS-1$

  222.     /**
  223.      * The server supports listing refs using protocol v2.
  224.      *
  225.      * @since 5.0
  226.      */
  227.     public static final String COMMAND_LS_REFS = "ls-refs"; //$NON-NLS-1$

  228.     /**
  229.      * The server supports fetch using protocol v2.
  230.      *
  231.      * @since 5.0
  232.      */
  233.     public static final String COMMAND_FETCH = "fetch"; //$NON-NLS-1$

  234.     /**
  235.      * The server supports the object-info capability.
  236.      *
  237.      * @since 5.13
  238.      */
  239.     public static final String COMMAND_OBJECT_INFO = "object-info"; //$NON-NLS-1$

  240.     /**
  241.      * HTTP header to set by clients to request a specific git protocol version
  242.      * in the HTTP transport.
  243.      *
  244.      * @since 5.11
  245.      */
  246.     public static final String PROTOCOL_HEADER = "Git-Protocol"; //$NON-NLS-1$

  247.     /**
  248.      * Environment variable to set by clients to request a specific git protocol
  249.      * in the file:// and ssh:// transports.
  250.      *
  251.      * @since 5.11
  252.      */
  253.     public static final String PROTOCOL_ENVIRONMENT_VARIABLE = "GIT_PROTOCOL"; //$NON-NLS-1$

  254.     /**
  255.      * Protocol V2 ref advertisement attribute containing the peeled object id
  256.      * for annotated tags.
  257.      *
  258.      * @since 5.11
  259.      */
  260.     public static final String REF_ATTR_PEELED = "peeled:"; //$NON-NLS-1$

  261.     /**
  262.      * Protocol V2 ref advertisement attribute containing the name of the ref
  263.      * for symbolic refs.
  264.      *
  265.      * @since 5.11
  266.      */
  267.     public static final String REF_ATTR_SYMREF_TARGET = "symref-target:"; //$NON-NLS-1$

  268.     /**
  269.      * Protocol V2 acknowledgments section header.
  270.      *
  271.      * @since 5.11
  272.      */
  273.     public static final String SECTION_ACKNOWLEDGMENTS = "acknowledgments"; //$NON-NLS-1$

  274.     /**
  275.      * Protocol V2 packfile section header.
  276.      *
  277.      * @since 5.11
  278.      */
  279.     public static final String SECTION_PACKFILE = "packfile"; //$NON-NLS-1$

  280.     /**
  281.      * Protocol V2 shallow-info section header.
  282.      *
  283.      * @since 6.3
  284.      */
  285.     public static final String SECTION_SHALLOW_INFO = "shallow-info"; //$NON-NLS-1$

  286.     /**
  287.      * Protocol announcement for protocol version 1. This is the same as V0,
  288.      * except for this initial line.
  289.      *
  290.      * @since 5.11
  291.      */
  292.     public static final String VERSION_1 = "version 1"; //$NON-NLS-1$

  293.     /**
  294.      * Protocol announcement for protocol version 2.
  295.      *
  296.      * @since 5.11
  297.      */
  298.     public static final String VERSION_2 = "version 2"; //$NON-NLS-1$

  299.     /**
  300.      * Protocol request for protocol version 2.
  301.      *
  302.      * @since 5.11
  303.      */
  304.     public static final String VERSION_2_REQUEST = "version=2"; //$NON-NLS-1$

  305.     /**
  306.      * The flush packet.
  307.      *
  308.      * @since 6.3
  309.      */
  310.     public static final String PACKET_FLUSH = "0000"; //$NON-NLS-1$

  311.     /**
  312.      * An alias for {@link #PACKET_FLUSH}. "Flush" is the name used in the C git
  313.      * documentation; the Java implementation calls this "end" in several
  314.      * places.
  315.      *
  316.      * @since 6.3
  317.      */
  318.     public static final String PACKET_END = PACKET_FLUSH;

  319.     /**
  320.      * The delimiter packet in protocol V2.
  321.      *
  322.      * @since 6.3
  323.      */
  324.     public static final String PACKET_DELIM = "0001"; //$NON-NLS-1$

  325.     /**
  326.      * A "deepen" packet beginning.
  327.      *
  328.      * @since 6.3
  329.      */
  330.     public static final String PACKET_DEEPEN = "deepen "; //$NON-NLS-1$

  331.     /**
  332.      * A "deepen-not" packet beginning.
  333.      *
  334.      * @since 6.3
  335.      */
  336.     public static final String PACKET_DEEPEN_NOT = "deepen-not "; //$NON-NLS-1$

  337.     /**
  338.      * A "deepen-since" packet beginning.
  339.      *
  340.      * @since 6.3
  341.      */
  342.     public static final String PACKET_DEEPEN_SINCE = "deepen-since "; //$NON-NLS-1$

  343.     /**
  344.      * An "ACK" packet beginning.
  345.      *
  346.      * @since 6.3
  347.      */
  348.     public static final String PACKET_ACK = "ACK "; //$NON-NLS-1$

  349.     /**
  350.      * A "done" packet beginning.
  351.      *
  352.      * @since 6.3
  353.      */
  354.     public static final String PACKET_DONE = "done"; //$NON-NLS-1$

  355.     /**
  356.      * A "ERR" packet beginning.
  357.      *
  358.      * @since 6.3
  359.      */
  360.     public static final String PACKET_ERR = "ERR "; //$NON-NLS-1$

  361.     /**
  362.      * A "have" packet beginning.
  363.      *
  364.      * @since 6.3
  365.      */
  366.     public static final String PACKET_HAVE = "have "; //$NON-NLS-1$

  367.     /**
  368.      * A "shallow" packet beginning.
  369.      *
  370.      * @since 6.3
  371.      */
  372.     public static final String PACKET_SHALLOW = OPTION_SHALLOW + ' ';

  373.     /**
  374.      * A "shallow" packet beginning.
  375.      *
  376.      * @since 6.3
  377.      */
  378.     public static final String PACKET_UNSHALLOW = "unshallow "; //$NON-NLS-1$

  379.     /**
  380.      * A "want" packet beginning.
  381.      *
  382.      * @since 6.3
  383.      */
  384.     public static final String PACKET_WANT = "want "; //$NON-NLS-1$

  385.     /**
  386.      * A "want-ref" packet beginning.
  387.      *
  388.      * @since 6.3
  389.      */
  390.     public static final String PACKET_WANT_REF = OPTION_WANT_REF + ' ';

  391.     enum MultiAck {
  392.         OFF, CONTINUE, DETAILED;
  393.     }

  394.     private GitProtocolConstants() {
  395.     }
  396. }