You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Status.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2011, Christian Halstrick <christian.halstrick@sap.com>
  3. * and other copyright owners as documented in the project's IP log.
  4. *
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Distribution License v1.0 which
  7. * accompanies this distribution, is reproduced below, and is
  8. * available at http://www.eclipse.org/org/documents/edl-v10.php
  9. *
  10. * All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials provided
  22. * with the distribution.
  23. *
  24. * - Neither the name of the Eclipse Foundation, Inc. nor the
  25. * names of its contributors may be used to endorse or promote
  26. * products derived from this software without specific prior
  27. * written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  34. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  41. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. */
  43. package org.eclipse.jgit.api;
  44. import java.util.Collections;
  45. import java.util.Set;
  46. import org.eclipse.jgit.lib.IndexDiff;
  47. /**
  48. * A class telling where the working-tree, the index and the current HEAD differ
  49. * from each other. Collections are exposed containing the paths of the modified
  50. * files. E.g. to find out which files are dirty in the working tree (modified
  51. * but not added) you would inspect the collection returned by
  52. * {@link #getModified()}.
  53. * <p>
  54. * The same path can be returned by multiple getters. E.g. if a modification has
  55. * been added to the index and afterwards the corresponding working tree file is
  56. * again modified this path will be returned by {@link #getModified()} and
  57. * {@link #getChanged()}
  58. */
  59. public class Status {
  60. private IndexDiff diff;
  61. /**
  62. * @param diff
  63. */
  64. public Status(IndexDiff diff) {
  65. super();
  66. this.diff = diff;
  67. }
  68. /**
  69. * @return list of files added to the index, not in HEAD (e.g. what you get
  70. * if you call 'git add ...' on a newly created file)
  71. */
  72. public Set<String> getAdded() {
  73. return Collections.unmodifiableSet(diff.getAdded());
  74. }
  75. /**
  76. * @return list of files changed from HEAD to index (e.g. what you get if
  77. * you modify an existing file and call 'git add ...' on it)
  78. */
  79. public Set<String> getChanged() {
  80. return Collections.unmodifiableSet(diff.getChanged());
  81. }
  82. /**
  83. * @return list of files removed from index, but in HEAD (e.g. what you get
  84. * if you call 'git rm ...' on a existing file)
  85. */
  86. public Set<String> getRemoved() {
  87. return Collections.unmodifiableSet(diff.getRemoved());
  88. }
  89. /**
  90. * @return list of files in index, but not filesystem (e.g. what you get if
  91. * you call 'rm ...' on a existing file)
  92. */
  93. public Set<String> getMissing() {
  94. return Collections.unmodifiableSet(diff.getMissing());
  95. }
  96. /**
  97. * @return list of files modified on disk relative to the index (e.g. what
  98. * you get if you modify an existing file without adding it to the
  99. * index)
  100. */
  101. public Set<String> getModified() {
  102. return Collections.unmodifiableSet(diff.getModified());
  103. }
  104. /**
  105. * @return list of files that are not ignored, and not in the index. (e.g.
  106. * what you get if you create a new file without adding it to the
  107. * index)
  108. */
  109. public Set<String> getUntracked() {
  110. return Collections.unmodifiableSet(diff.getUntracked());
  111. }
  112. /**
  113. * @return list of files that are in conflict. (e.g what you get if you
  114. * modify file that was modified by someone else in the meantime)
  115. */
  116. public Set<String> getConflicting() {
  117. return Collections.unmodifiableSet(diff.getConflicting());
  118. }
  119. }