aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.lfs.test')
-rw-r--r--org.eclipse.jgit.lfs.test/.classpath20
-rw-r--r--org.eclipse.jgit.lfs.test/.gitignore2
-rw-r--r--org.eclipse.jgit.lfs.test/.project34
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs518
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.ui.prefs66
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.tasks.ui.prefs3
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs2
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.api.tools.prefs104
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.core.prefs2
-rw-r--r--org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.prefs34
-rw-r--r--org.eclipse.jgit.lfs.test/BUILD31
-rw-r--r--org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF31
-rw-r--r--org.eclipse.jgit.lfs.test/build.properties5
-rw-r--r--org.eclipse.jgit.lfs.test/plugin.properties2
-rw-r--r--org.eclipse.jgit.lfs.test/pom.xml90
-rw-r--r--org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java62
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsConfigGitTest.java301
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsGitTest.java162
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/internal/LfsConnectionFactoryTest.java319
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectIdTest.java564
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java303
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LfsPointerFilterTest.java181
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java398
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/MutableLongObjectIdTest.java59
26 files changed, 3297 insertions, 0 deletions
diff --git a/org.eclipse.jgit.lfs.test/.classpath b/org.eclipse.jgit.lfs.test/.classpath
new file mode 100644
index 0000000000..9737446f46
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.classpath
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src">
+ <attributes>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="tst">
+ <attributes>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jgit.lfs.test/.gitignore b/org.eclipse.jgit.lfs.test/.gitignore
new file mode 100644
index 0000000000..4dc009173e
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin
diff --git a/org.eclipse.jgit.lfs.test/.project b/org.eclipse.jgit.lfs.test/.project
new file mode 100644
index 0000000000..c5dddb0e94
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jgit.lfs.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000..99f26c0203
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 0000000000..5a0ad22d2a
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..362915de03
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,518 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
+org.eclipse.jdt.core.compiler.problem.deadCode=error
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=error
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=17
+org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
+org.eclipse.jdt.core.formatter.align_with_spaces=false
+org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=0
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0
+org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assertion_message=0
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_record_components=16
+org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
+org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false
+org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
+org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.text_block_indentation=0
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000000..5cfb8b6ac6
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,66 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_JGit Format
+formatter_settings_version=21
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;org;com;
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.tasks.ui.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.tasks.ui.prefs
new file mode 100644
index 0000000000..3dec4d97c7
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.tasks.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+project.repository.kind=bugzilla
+project.repository.url=https\://bugs.eclipse.org/bugs
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs
new file mode 100644
index 0000000000..984263dd94
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs
@@ -0,0 +1,2 @@
+commit.comment.template=${task.description}\n\nBug\: ${task.key}
+eclipse.preferences.version=1
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.api.tools.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.api.tools.prefs
new file mode 100644
index 0000000000..c0030ded71
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.api.tools.prefs
@@ -0,0 +1,104 @@
+ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error
+ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
+ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
+API_USE_SCAN_FIELD_SEVERITY=Error
+API_USE_SCAN_METHOD_SEVERITY=Error
+API_USE_SCAN_TYPE_SEVERITY=Error
+CLASS_ELEMENT_TYPE_ADDED_FIELD=Error
+CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
+CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error
+CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error
+CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error
+CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error
+ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error
+ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error
+ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+FIELD_ELEMENT_TYPE_ADDED_VALUE=Error
+FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error
+FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error
+FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error
+FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error
+ILLEGAL_EXTEND=Warning
+ILLEGAL_IMPLEMENT=Warning
+ILLEGAL_INSTANTIATE=Warning
+ILLEGAL_OVERRIDE=Warning
+ILLEGAL_REFERENCE=Warning
+INTERFACE_ELEMENT_TYPE_ADDED_DEFAULT_METHOD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+INVALID_ANNOTATION=Ignore
+INVALID_JAVADOC_TAG=Ignore
+INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error
+LEAK_EXTEND=Warning
+LEAK_FIELD_DECL=Warning
+LEAK_IMPLEMENT=Warning
+LEAK_METHOD_PARAM=Warning
+LEAK_METHOD_RETURN_TYPE=Warning
+METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
+METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+MISSING_EE_DESCRIPTIONS=Warning
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
+UNUSED_PROBLEM_FILTERS=Warning
+automatically_removed_unused_problem_filters=false
+changed_execution_env=Error
+eclipse.preferences.version=1
+incompatible_api_component_version=Error
+incompatible_api_component_version_include_major_without_breaking_change=Disabled
+incompatible_api_component_version_include_minor_without_api_change=Disabled
+incompatible_api_component_version_report_major_without_breaking_change=Warning
+incompatible_api_component_version_report_minor_without_api_change=Ignore
+invalid_since_tag_version=Error
+malformed_since_tag=Error
+missing_since_tag=Error
+report_api_breakage_when_major_version_incremented=Disabled
+report_resolution_errors_api_component=Warning
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.core.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000000..923c37fb8d
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+resolve.requirebundle=false
diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.prefs
new file mode 100644
index 0000000000..2174e4fd5b
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.pde.prefs
@@ -0,0 +1,34 @@
+compilers.f.unresolved-features=1
+compilers.f.unresolved-plugins=1
+compilers.incompatible-environment=1
+compilers.p.build=1
+compilers.p.build.bin.includes=1
+compilers.p.build.encodings=2
+compilers.p.build.java.compiler=2
+compilers.p.build.java.compliance=1
+compilers.p.build.missing.output=2
+compilers.p.build.output.library=1
+compilers.p.build.source.library=1
+compilers.p.build.src.includes=1
+compilers.p.deprecated=1
+compilers.p.discouraged-class=1
+compilers.p.internal=1
+compilers.p.missing-packages=2
+compilers.p.missing-version-export-package=2
+compilers.p.missing-version-import-package=2
+compilers.p.missing-version-require-bundle=2
+compilers.p.no-required-att=0
+compilers.p.no.automatic.module=1
+compilers.p.not-externalized-att=2
+compilers.p.service.component.without.lazyactivation=1
+compilers.p.unknown-attribute=1
+compilers.p.unknown-class=1
+compilers.p.unknown-element=1
+compilers.p.unknown-identifier=1
+compilers.p.unknown-resource=1
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.s.create-docs=false
+compilers.s.doc-folder=doc
+compilers.s.open-tags=1
+eclipse.preferences.version=1
diff --git a/org.eclipse.jgit.lfs.test/BUILD b/org.eclipse.jgit.lfs.test/BUILD
new file mode 100644
index 0000000000..4665f675b1
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/BUILD
@@ -0,0 +1,31 @@
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+load("@rules_java//java:defs.bzl", "java_library")
+
+package(default_visibility = ["//visibility:public"])
+
+junit_tests(
+ name = "lfs",
+ srcs = glob(["tst/**/*.java"]),
+ tags = ["lfs"],
+ deps = [
+ ":helpers",
+ "//lib:junit",
+ "//lib:slf4j-api",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ ],
+)
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = glob(["src/**/*.java"]),
+ deps = [
+ "//lib:junit",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ ],
+)
diff --git a/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a6befcabee
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Automatic-Module-Name: org.eclipse.jgit.lfs.test
+Bundle-SymbolicName: org.eclipse.jgit.lfs.test
+Bundle-Version: 7.4.0.qualifier
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-SCM: url=https://github.com/eclipse-jgit/jgit, connection=scm:git:https://eclipse.gerrithub.io/eclipse-jgit/jgit.git, developerConnection=scm:git:https://eclipse.gerrithub.io/a/eclipse-jgit/jgit.git
+Import-Package: org.eclipse.jgit.api;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.attributes;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.internal.storage.dfs;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.internal.storage.file;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.junit;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.lfs;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.lfs.errors;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.lfs.internal;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.lfs.lib;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.lib;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.revwalk;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.transport;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.transport.http;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.treewalk;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.treewalk.filter;version="[7.4.0,7.5.0)",
+ org.eclipse.jgit.util;version="[7.4.0,7.5.0)",
+ org.hamcrest.core;version="[1.1.0,3.0.0)",
+ org.junit;version="[4.13,5.0.0)",
+ org.junit.runner;version="[4.13,5.0.0)",
+ org.junit.runners;version="[4.13,5.0.0)"
+Export-Package: org.eclipse.jgit.lfs.test;version="7.4.0";x-friends:="org.eclipse.jgit.lfs.server.test"
diff --git a/org.eclipse.jgit.lfs.test/build.properties b/org.eclipse.jgit.lfs.test/build.properties
new file mode 100644
index 0000000000..47ae0916a2
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/build.properties
@@ -0,0 +1,5 @@
+source.. = tst/, src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties
diff --git a/org.eclipse.jgit.lfs.test/plugin.properties b/org.eclipse.jgit.lfs.test/plugin.properties
new file mode 100644
index 0000000000..ab78575d69
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/plugin.properties
@@ -0,0 +1,2 @@
+Bundle-Name=JGit LFS Tests
+Bundle-Vendor=Eclipse JGit
diff --git a/org.eclipse.jgit.lfs.test/pom.xml b/org.eclipse.jgit.lfs.test/pom.xml
new file mode 100644
index 0000000000..01a0c29ab8
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2015 Matthias Sohn <matthias.sohn@sap.com> and others
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Distribution License v. 1.0 which is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ SPDX-License-Identifier: BSD-3-Clause
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit-parent</artifactId>
+ <version>7.4.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.jgit.lfs.test</artifactId>
+ <name>JGit - Large File Storage Tests</name>
+
+ <description>
+ Tests for the Large File Extension (LFS).
+ </description>
+
+ <properties>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.lfs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.junit</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testSourceDirectory>tst/</testSourceDirectory>
+ <sourceDirectory>src/</sourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>tst-rsrc/</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>@{argLine} -Djava.io.tmpdir=${project.build.directory} -Xmx512m</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java b/org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java
new file mode 100644
index 0000000000..eaa8a90f45
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/src/org/eclipse/jgit/lfs/test/LongObjectIdTestUtils.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.lfs.test;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.io.BufferedInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.MessageDigest;
+
+import org.eclipse.jgit.lfs.lib.Constants;
+import org.eclipse.jgit.lfs.lib.LongObjectId;
+
+public class LongObjectIdTestUtils {
+
+ /**
+ * Create id as hash of the given string.
+ *
+ * @param s
+ * the string to hash
+ * @return id calculated by hashing string
+ */
+ public static LongObjectId hash(String s) {
+ MessageDigest md = Constants.newMessageDigest();
+ md.update(s.getBytes(UTF_8));
+ return LongObjectId.fromRaw(md.digest());
+ }
+
+ /**
+ * Create id as hash of a file content
+ *
+ * @param file
+ * the file to hash
+ * @return id calculated by hashing file content
+ * @throws FileNotFoundException
+ * if file doesn't exist
+ * @throws IOException
+ */
+ public static LongObjectId hash(Path file)
+ throws FileNotFoundException, IOException {
+ MessageDigest md = Constants.newMessageDigest();
+ try (InputStream is = new BufferedInputStream(
+ Files.newInputStream(file))) {
+ final byte[] buffer = new byte[4096];
+ for (int read = 0; (read = is.read(buffer)) != -1;) {
+ md.update(buffer, 0, read);
+ }
+ }
+ return LongObjectId.fromRaw(md.digest());
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsConfigGitTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsConfigGitTest.java
new file mode 100644
index 0000000000..3ac41571a4
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsConfigGitTest.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2022, Matthias Fromme <mfromme@dspace.de>
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.lfs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
+import org.eclipse.jgit.attributes.FilterCommand;
+import org.eclipse.jgit.attributes.FilterCommandRegistry;
+import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lfs.internal.LfsConnectionFactory;
+import org.eclipse.jgit.lfs.lib.Constants;
+import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.transport.http.HttpConnection;
+import org.eclipse.jgit.util.HttpSupport;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test if the lfs config is used in the correct way during checkout.
+ *
+ * Two lfs-files are created, one that comes before .gitattributes and
+ * .lfsconfig in git order (".aaa.txt") and one that comes after ("zzz.txt").
+ *
+ * During checkout/reset it is tested if the correct version of the lfs config
+ * is used.
+ *
+ * TODO: The current behavior seems a little bit strange/unintuitive. Some files
+ * are checked out before and some after the config files. This leads to the
+ * behavior, that during a single command the config changes. Since this seems
+ * to be the same way in native git, the behavior is accepted for now.
+ *
+ */
+public class LfsConfigGitTest extends RepositoryTestCase {
+
+ private static final String SMUDGE_NAME = org.eclipse.jgit.lib.Constants.BUILTIN_FILTER_PREFIX
+ + Constants.ATTR_FILTER_DRIVER_PREFIX
+ + org.eclipse.jgit.lib.Constants.ATTR_FILTER_TYPE_SMUDGE;
+
+ private static final String LFS_SERVER_URI1 = "https://lfs.server1/test/uri";
+
+ private static final String EXPECTED_SERVER_URL1 = LFS_SERVER_URI1
+ + Protocol.OBJECTS_LFS_ENDPOINT;
+
+ private static final String LFS_SERVER_URI2 = "https://lfs.server2/test/uri";
+
+ private static final String EXPECTED_SERVER_URL2 = LFS_SERVER_URI2
+ + Protocol.OBJECTS_LFS_ENDPOINT;
+
+ private static final String LFS_SERVER_URI3 = "https://lfs.server3/test/uri";
+
+ private static final String EXPECTED_SERVER_URL3 = LFS_SERVER_URI3
+ + Protocol.OBJECTS_LFS_ENDPOINT;
+
+ private static final String FAKE_LFS_POINTER1 = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:6ce9fab52ee9a6c4c097def4e049c6acdeba44c99d26e83ba80adec1473c9b2d\n"
+ + "size 253952\n";
+
+ private static final String FAKE_LFS_POINTER2 = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:a4b711cd989863ae2038758a62672138347abbbae4076a7ad3a545fda7d08f82\n"
+ + "size 67072\n";
+
+ private static List<String> checkoutURLs = new ArrayList<>();
+
+ static class SmudgeFilterMock extends FilterCommand {
+ public SmudgeFilterMock(Repository db, InputStream in,
+ OutputStream out) throws IOException {
+ super(in, out);
+ HttpConnection lfsServerConn = LfsConnectionFactory.getLfsConnection(db,
+ HttpSupport.METHOD_POST, Protocol.OPERATION_DOWNLOAD);
+ checkoutURLs.add(lfsServerConn.getURL().toString());
+ }
+
+ @Override
+ public int run() throws IOException {
+ // Stupid no impl
+ in.transferTo(out);
+ return -1;
+ }
+ }
+
+ @BeforeClass
+ public static void installLfs() {
+ FilterCommandRegistry.register(SMUDGE_NAME, SmudgeFilterMock::new);
+ }
+
+ @AfterClass
+ public static void removeLfs() {
+ FilterCommandRegistry.unregister(SMUDGE_NAME);
+ }
+
+ private Git git;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ git = new Git(db);
+ // commit something
+ writeTrashFile("Test.txt", "Hello world");
+ git.add().addFilepattern("Test.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ // prepare the config for LFS
+ StoredConfig config = git.getRepository().getConfig();
+ config.setString("filter", "lfs", "smudge", SMUDGE_NAME);
+ config.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_AUTOCRLF, "false");
+ config.save();
+
+ fileBefore = null;
+ fileAfter = null;
+ configFile = null;
+ gitAttributesFile = null;
+ }
+
+ File fileBefore;
+
+ File fileAfter;
+
+ File configFile;
+
+ File gitAttributesFile;
+
+ private void createLfsFiles(String lfsPointer) throws Exception {
+ //File to be checked out before lfs config
+ String fileNameBefore = ".aaa.txt";
+ fileBefore = writeTrashFile(fileNameBefore, lfsPointer);
+ git.add().addFilepattern(fileNameBefore).call();
+
+ // File to be checked out after lfs config
+ String fileNameAfter = "zzz.txt";
+ fileAfter = writeTrashFile(fileNameAfter, lfsPointer);
+ git.add().addFilepattern(fileNameAfter).call();
+
+ git.commit().setMessage("Commit LFS Pointer files").call();
+ }
+
+
+ private String addLfsConfigFiles(String lfsServerUrl) throws Exception {
+ // Add config files to the repo
+ String lfsConfig1 = createLfsConfig(lfsServerUrl);
+ git.add().addFilepattern(Constants.DOT_LFS_CONFIG).call();
+ // Modify gitattributes on second call, to force checkout too.
+ if (gitAttributesFile == null) {
+ gitAttributesFile = writeTrashFile(".gitattributes",
+ "*.txt filter=lfs");
+ } else {
+ gitAttributesFile = writeTrashFile(".gitattributes",
+ "*.txt filter=lfs\n");
+ }
+
+ git.add().addFilepattern(".gitattributes").call();
+ git.commit().setMessage("Commit config files").call();
+ return lfsConfig1;
+ }
+
+ private String createLfsConfig(String lfsServerUrl) throws IOException {
+ String lfsConfig1 = "[lfs]\n url = " + lfsServerUrl;
+ configFile = writeTrashFile(Constants.DOT_LFS_CONFIG, lfsConfig1);
+ return lfsConfig1;
+ }
+
+ @Test
+ public void checkoutLfsObjects_reset() throws Exception {
+ createLfsFiles(FAKE_LFS_POINTER1);
+ String lfsConfig1 = addLfsConfigFiles(LFS_SERVER_URI1);
+
+ // Delete files to force action on reset
+ assertTrue(configFile.delete());
+ assertTrue(fileBefore.delete());
+ assertTrue(fileAfter.delete());
+
+ assertTrue(gitAttributesFile.delete());
+
+ // create config file with different url
+ createLfsConfig(LFS_SERVER_URI3);
+
+ checkoutURLs.clear();
+ git.reset().setMode(ResetType.HARD).call();
+
+ checkFile(configFile, lfsConfig1);
+ checkFile(fileBefore, FAKE_LFS_POINTER1);
+ checkFile(fileAfter, FAKE_LFS_POINTER1);
+
+ assertEquals(2, checkoutURLs.size());
+ // TODO: Should may be EXPECTED_SERVR_URL1
+ assertEquals(EXPECTED_SERVER_URL3, checkoutURLs.get(0));
+ assertEquals(EXPECTED_SERVER_URL1, checkoutURLs.get(1));
+ }
+
+ @Test
+ public void checkoutLfsObjects_BranchSwitch() throws Exception {
+ // Create a new branch "URL1" and add config files
+ git.checkout().setCreateBranch(true).setName("URL1").call();
+
+ createLfsFiles(FAKE_LFS_POINTER1);
+ String lfsConfig1 = addLfsConfigFiles(LFS_SERVER_URI1);
+
+ // Create a second new branch "URL2" and add config files
+ git.checkout().setCreateBranch(true).setName("URL2").call();
+
+ createLfsFiles(FAKE_LFS_POINTER2);
+ String lfsConfig2 = addLfsConfigFiles(LFS_SERVER_URI2);
+
+ checkFile(configFile, lfsConfig2);
+ checkFile(fileBefore, FAKE_LFS_POINTER2);
+ checkFile(fileAfter, FAKE_LFS_POINTER2);
+
+ checkoutURLs.clear();
+ git.checkout().setName("URL1").call();
+
+ checkFile(configFile, lfsConfig1);
+ checkFile(fileBefore, FAKE_LFS_POINTER1);
+ checkFile(fileAfter, FAKE_LFS_POINTER1);
+
+ assertEquals(2, checkoutURLs.size());
+ // TODO: Should may be EXPECTED_SERVR_URL1
+ assertEquals(EXPECTED_SERVER_URL2, checkoutURLs.get(0));
+ assertEquals(EXPECTED_SERVER_URL1, checkoutURLs.get(1));
+
+ checkoutURLs.clear();
+ git.checkout().setName("URL2").call();
+
+ checkFile(configFile, lfsConfig2);
+ checkFile(fileBefore, FAKE_LFS_POINTER2);
+ checkFile(fileAfter, FAKE_LFS_POINTER2);
+
+ assertEquals(2, checkoutURLs.size());
+ // TODO: Should may be EXPECTED_SERVR_URL2
+ assertEquals(EXPECTED_SERVER_URL1, checkoutURLs.get(0));
+ assertEquals(EXPECTED_SERVER_URL2, checkoutURLs.get(1));
+ }
+
+ @Test
+ public void checkoutLfsObjects_BranchSwitch_ModifiedLocal()
+ throws Exception {
+
+ // Create a new branch "URL1" and add config files
+ git.checkout().setCreateBranch(true).setName("URL1").call();
+
+ createLfsFiles(FAKE_LFS_POINTER1);
+ addLfsConfigFiles(LFS_SERVER_URI1);
+
+ // Create a second new branch "URL2" and add config files
+ git.checkout().setCreateBranch(true).setName("URL2").call();
+
+ createLfsFiles(FAKE_LFS_POINTER2);
+ addLfsConfigFiles(LFS_SERVER_URI1);
+
+ // create config file with different url
+ assertTrue(configFile.delete());
+ String lfsConfig3 = createLfsConfig(LFS_SERVER_URI3);
+
+ checkFile(configFile, lfsConfig3);
+ checkFile(fileBefore, FAKE_LFS_POINTER2);
+ checkFile(fileAfter, FAKE_LFS_POINTER2);
+
+ checkoutURLs.clear();
+ git.checkout().setName("URL1").call();
+
+ checkFile(fileBefore, FAKE_LFS_POINTER1);
+ checkFile(fileAfter, FAKE_LFS_POINTER1);
+ checkFile(configFile, lfsConfig3);
+
+ assertEquals(2, checkoutURLs.size());
+
+ assertEquals(EXPECTED_SERVER_URL3, checkoutURLs.get(0));
+ assertEquals(EXPECTED_SERVER_URL3, checkoutURLs.get(1));
+
+ checkoutURLs.clear();
+ git.checkout().setName("URL2").call();
+
+ checkFile(fileBefore, FAKE_LFS_POINTER2);
+ checkFile(fileAfter, FAKE_LFS_POINTER2);
+ checkFile(configFile, lfsConfig3);
+
+ assertEquals(2, checkoutURLs.size());
+ assertEquals(EXPECTED_SERVER_URL3, checkoutURLs.get(0));
+ assertEquals(EXPECTED_SERVER_URL3, checkoutURLs.get(1));
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsGitTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsGitTest.java
new file mode 100644
index 0000000000..3e83c8ef49
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/LfsGitTest.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2021, 2022 Thomas Wolf <thomas.wolf@paranor.ch> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.lfs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
+import org.eclipse.jgit.attributes.FilterCommandRegistry;
+import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lfs.lib.Constants;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class LfsGitTest extends RepositoryTestCase {
+
+ private static final String SMUDGE_NAME = org.eclipse.jgit.lib.Constants.BUILTIN_FILTER_PREFIX
+ + Constants.ATTR_FILTER_DRIVER_PREFIX
+ + org.eclipse.jgit.lib.Constants.ATTR_FILTER_TYPE_SMUDGE;
+
+ private static final String CLEAN_NAME = org.eclipse.jgit.lib.Constants.BUILTIN_FILTER_PREFIX
+ + Constants.ATTR_FILTER_DRIVER_PREFIX
+ + org.eclipse.jgit.lib.Constants.ATTR_FILTER_TYPE_CLEAN;
+
+ @BeforeClass
+ public static void installLfs() {
+ FilterCommandRegistry.register(SMUDGE_NAME, SmudgeFilter.FACTORY);
+ FilterCommandRegistry.register(CLEAN_NAME, CleanFilter.FACTORY);
+ }
+
+ @AfterClass
+ public static void removeLfs() {
+ FilterCommandRegistry.unregister(SMUDGE_NAME);
+ FilterCommandRegistry.unregister(CLEAN_NAME);
+ }
+
+ private Git git;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ git = new Git(db);
+ // commit something
+ writeTrashFile("Test.txt", "Hello world");
+ git.add().addFilepattern("Test.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ // prepare the config for LFS
+ StoredConfig config = git.getRepository().getConfig();
+ config.setString("filter", "lfs", "clean", CLEAN_NAME);
+ config.setString("filter", "lfs", "smudge", SMUDGE_NAME);
+ config.save();
+ }
+
+ @Test
+ public void testBranchSwitch() throws Exception {
+ git.branchCreate().setName("abranch").call();
+ git.checkout().setName("abranch").call();
+ File aFile = writeTrashFile("a.bin", "aaa");
+ writeTrashFile(".gitattributes", "a.bin filter=lfs");
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("acommit").call();
+ git.checkout().setName("master").call();
+ git.branchCreate().setName("bbranch").call();
+ git.checkout().setName("bbranch").call();
+ File bFile = writeTrashFile("b.bin", "bbb");
+ writeTrashFile(".gitattributes", "b.bin filter=lfs");
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("bcommit").call();
+ git.checkout().setName("abranch").call();
+ checkFile(aFile, "aaa");
+ git.checkout().setName("bbranch").call();
+ checkFile(bFile, "bbb");
+ }
+
+ @Test
+ public void checkoutNonLfsPointer() throws Exception {
+ String content = "size_t\nsome_function(void* ptr);\n";
+ File smallFile = writeTrashFile("Test.txt", content);
+ StringBuilder largeContent = new StringBuilder(
+ LfsPointer.SIZE_THRESHOLD * 4);
+ while (largeContent.length() < LfsPointer.SIZE_THRESHOLD * 4) {
+ largeContent.append(content);
+ }
+ File largeFile = writeTrashFile("large.txt", largeContent.toString());
+ fsTick(largeFile);
+ git.add().addFilepattern("Test.txt").addFilepattern("large.txt").call();
+ git.commit().setMessage("Text files").call();
+ writeTrashFile(".gitattributes", "*.txt filter=lfs");
+ git.add().addFilepattern(".gitattributes").call();
+ git.commit().setMessage("attributes").call();
+ assertTrue(smallFile.delete());
+ assertTrue(largeFile.delete());
+ // This reset will run the two text files through the smudge filter
+ git.reset().setMode(ResetType.HARD).call();
+ assertTrue(smallFile.exists());
+ assertTrue(largeFile.exists());
+ checkFile(smallFile, content);
+ checkFile(largeFile, largeContent.toString());
+ // Modify the large file
+ largeContent.append(content);
+ writeTrashFile("large.txt", largeContent.toString());
+ // This should convert largeFile to an LFS pointer
+ git.add().addFilepattern("large.txt").call();
+ git.commit().setMessage("Large modified").call();
+ String lfsPtr = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:d041ab19bd7edd899b3c0450d0f61819f96672f0b22d26c9753abc62e1261614\n"
+ + "size 858\n";
+ assertEquals("[.gitattributes, mode:100644, content:*.txt filter=lfs]"
+ + "[Test.txt, mode:100644, content:" + content + ']'
+ + "[large.txt, mode:100644, content:" + lfsPtr + ']',
+ indexState(CONTENT));
+ // Verify the file has been saved
+ File savedFile = new File(db.getDirectory(), "lfs");
+ savedFile = new File(savedFile, "objects");
+ savedFile = new File(savedFile, "d0");
+ savedFile = new File(savedFile, "41");
+ savedFile = new File(savedFile,
+ "d041ab19bd7edd899b3c0450d0f61819f96672f0b22d26c9753abc62e1261614");
+ String saved = new String(Files.readAllBytes(savedFile.toPath()),
+ StandardCharsets.UTF_8);
+ assertEquals(saved, largeContent.toString());
+
+ assertTrue(smallFile.delete());
+ assertTrue(largeFile.delete());
+ git.reset().setMode(ResetType.HARD).call();
+ assertTrue(smallFile.exists());
+ assertTrue(largeFile.exists());
+ checkFile(smallFile, content);
+ checkFile(largeFile, largeContent.toString());
+ assertEquals("[.gitattributes, mode:100644, content:*.txt filter=lfs]"
+ + "[Test.txt, mode:100644, content:" + content + ']'
+ + "[large.txt, mode:100644, content:" + lfsPtr + ']',
+ indexState(CONTENT));
+ git.add().addFilepattern("Test.txt").call();
+ git.commit().setMessage("Small committed again").call();
+ String lfsPtrSmall = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:9110463275fb0e2f0e9fdeaf84e598e62915666161145cf08927079119cc7814\n"
+ + "size 33\n";
+ assertEquals("[.gitattributes, mode:100644, content:*.txt filter=lfs]"
+ + "[Test.txt, mode:100644, content:" + lfsPtrSmall + ']'
+ + "[large.txt, mode:100644, content:" + lfsPtr + ']',
+ indexState(CONTENT));
+
+ assertTrue(git.status().call().isClean());
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/internal/LfsConnectionFactoryTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/internal/LfsConnectionFactoryTest.java
new file mode 100644
index 0000000000..ee8e893b3e
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/internal/LfsConnectionFactoryTest.java
@@ -0,0 +1,319 @@
+/*
+ * Copyright (C) 2022 Nail Samatov <sanail@yandex.ru> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.lfs.internal;
+
+import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.RemoteAddCommand;
+import org.eclipse.jgit.attributes.FilterCommandRegistry;
+import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lfs.CleanFilter;
+import org.eclipse.jgit.lfs.Protocol;
+import org.eclipse.jgit.lfs.SmudgeFilter;
+import org.eclipse.jgit.lfs.errors.LfsConfigInvalidException;
+import org.eclipse.jgit.lfs.lib.Constants;
+import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnection;
+import org.eclipse.jgit.util.HttpSupport;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class LfsConnectionFactoryTest extends RepositoryTestCase {
+
+ private static final String SMUDGE_NAME = org.eclipse.jgit.lib.Constants.BUILTIN_FILTER_PREFIX
+ + Constants.ATTR_FILTER_DRIVER_PREFIX
+ + org.eclipse.jgit.lib.Constants.ATTR_FILTER_TYPE_SMUDGE;
+
+ private static final String CLEAN_NAME = org.eclipse.jgit.lib.Constants.BUILTIN_FILTER_PREFIX
+ + Constants.ATTR_FILTER_DRIVER_PREFIX
+ + org.eclipse.jgit.lib.Constants.ATTR_FILTER_TYPE_CLEAN;
+
+ private final static String LFS_SERVER_URL1 = "https://lfs.server1/test/uri";
+
+ private final static String LFS_SERVER_URL2 = "https://lfs.server2/test/uri";
+
+ private final static String ORIGIN_URL = "https://git.server/test/uri";
+
+ private Git git;
+
+ @BeforeClass
+ public static void installLfs() {
+ FilterCommandRegistry.register(SMUDGE_NAME, SmudgeFilter.FACTORY);
+ FilterCommandRegistry.register(CLEAN_NAME, CleanFilter.FACTORY);
+ }
+
+ @AfterClass
+ public static void removeLfs() {
+ FilterCommandRegistry.unregister(SMUDGE_NAME);
+ FilterCommandRegistry.unregister(CLEAN_NAME);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ git = new Git(db);
+
+ // Just to have a non empty repo
+ writeTrashFile("Test.txt", "Hello world from the LFS Factory Test");
+ git.add().addFilepattern("Test.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ }
+
+ @Test
+ public void lfsUrlFromRemoteUrlWithDotGit() throws Exception {
+ addRemoteUrl("https://localhost/repo.git");
+ checkLfsUrl("https://localhost/repo.git/info/lfs");
+ }
+
+ @Test
+ public void lfsUrlFromRemoteUrlWithoutDotGit() throws Exception {
+ addRemoteUrl("https://localhost/repo");
+ checkLfsUrl("https://localhost/repo.git/info/lfs");
+ }
+
+ @Test
+ public void lfsUrlFromLocalConfig() throws Exception {
+ addRemoteUrl("https://localhost/repo");
+
+ @SuppressWarnings("restriction")
+ StoredConfig cfg = db.getConfig();
+ cfg.setString(ConfigConstants.CONFIG_SECTION_LFS,
+ null,
+ ConfigConstants.CONFIG_KEY_URL,
+ "https://localhost/repo/lfs");
+ cfg.save();
+
+ checkLfsUrl("https://localhost/repo/lfs");
+ }
+
+ @Test
+ public void lfsUrlFromOriginConfig() throws Exception {
+ addRemoteUrl("https://localhost/repo");
+
+ @SuppressWarnings("restriction")
+ StoredConfig cfg = db.getConfig();
+ cfg.setString(ConfigConstants.CONFIG_SECTION_LFS,
+ org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME,
+ ConfigConstants.CONFIG_KEY_URL,
+ "https://localhost/repo/lfs");
+ cfg.save();
+
+ checkLfsUrl("https://localhost/repo/lfs");
+ }
+
+ @Test
+ public void lfsUrlNotConfigured() throws Exception {
+ assertThrows(LfsConfigInvalidException.class,
+ () -> LfsConnectionFactory.getLfsConnection(db,
+ HttpSupport.METHOD_POST, Protocol.OPERATION_DOWNLOAD));
+ }
+
+ @Test
+ public void checkGetLfsConnection_lfsurl_lfsconfigFromWorkingDir()
+ throws Exception {
+ writeLfsConfig();
+ checkLfsUrl(LFS_SERVER_URL1);
+ }
+
+ @Test
+ public void checkGetLfsConnection_lfsurl_lfsconfigFromIndex()
+ throws Exception {
+ writeLfsConfig();
+ git.add().addFilepattern(Constants.DOT_LFS_CONFIG).call();
+ deleteTrashFile(Constants.DOT_LFS_CONFIG);
+ checkLfsUrl(LFS_SERVER_URL1);
+ }
+
+ @Test
+ public void checkGetLfsConnection_lfsurl_lfsconfigFromHEAD()
+ throws Exception {
+ writeLfsConfig();
+ git.add().addFilepattern(Constants.DOT_LFS_CONFIG).call();
+ git.commit().setMessage("Commit LFS Config").call();
+
+ /*
+ * reading .lfsconfig from HEAD seems only testable using a bare repo,
+ * since otherwise working tree or index are used
+ */
+ File directory = createTempDirectory("testBareRepo");
+ try (Repository bareRepoDb = Git.cloneRepository()
+ .setDirectory(directory)
+ .setURI(db.getDirectory().toURI().toString()).setBare(true)
+ .call().getRepository()) {
+
+ checkLfsUrl(LFS_SERVER_URL1);
+ }
+ }
+
+ @Test
+ public void checkGetLfsConnection_remote_lfsconfigFromWorkingDir()
+ throws Exception {
+ addRemoteUrl(ORIGIN_URL);
+ writeLfsConfig(LFS_SERVER_URL1, "lfs", DEFAULT_REMOTE_NAME, "url");
+ checkLfsUrl(LFS_SERVER_URL1);
+ }
+
+ /**
+ * Test the config file precedence.
+ *
+ * Checking only with the local repository config is sufficient since from
+ * that point the "normal" precedence is used.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void checkGetLfsConnection_ConfigFilePrecedence_lfsconfigFromWorkingDir()
+ throws Exception {
+ writeLfsConfig();
+ checkLfsUrl(LFS_SERVER_URL1);
+
+ StoredConfig config = git.getRepository().getConfig();
+ config.setString(ConfigConstants.CONFIG_SECTION_LFS, null,
+ ConfigConstants.CONFIG_KEY_URL, LFS_SERVER_URL2);
+ config.save();
+
+ checkLfsUrl(LFS_SERVER_URL2);
+ }
+
+ @Test
+ public void checkGetLfsConnection_InvalidLfsConfig_WorkingDir()
+ throws Exception {
+ writeInvalidLfsConfig();
+ LfsConfigInvalidException actualException = assertThrows(
+ LfsConfigInvalidException.class, () -> {
+ LfsConnectionFactory.getLfsConnection(db, HttpSupport.METHOD_POST,
+ Protocol.OPERATION_DOWNLOAD);
+ });
+ assertTrue(getStackTrace(actualException)
+ .contains("Invalid line in config file"));
+ }
+
+ @Test
+ public void checkGetLfsConnection_InvalidLfsConfig_Index()
+ throws Exception {
+ writeInvalidLfsConfig();
+ git.add().addFilepattern(Constants.DOT_LFS_CONFIG).call();
+ deleteTrashFile(Constants.DOT_LFS_CONFIG);
+ LfsConfigInvalidException actualException = assertThrows(
+ LfsConfigInvalidException.class, () -> {
+ LfsConnectionFactory.getLfsConnection(db, HttpSupport.METHOD_POST,
+ Protocol.OPERATION_DOWNLOAD);
+ });
+ assertTrue(getStackTrace(actualException)
+ .contains("Invalid line in config file"));
+ }
+
+ @Test
+ public void checkGetLfsConnection_InvalidLfsConfig_HEAD() throws Exception {
+ writeInvalidLfsConfig();
+ git.add().addFilepattern(Constants.DOT_LFS_CONFIG).call();
+ git.commit().setMessage("Commit LFS Config").call();
+
+ /*
+ * reading .lfsconfig from HEAD seems only testable using a bare repo,
+ * since otherwise working tree or index are used
+ */
+ File directory = createTempDirectory("testBareRepo");
+ try (Repository bareRepoDb = Git.cloneRepository()
+ .setDirectory(directory)
+ .setURI(db.getDirectory().toURI().toString()).setBare(true)
+ .call().getRepository()) {
+ LfsConfigInvalidException actualException = assertThrows(
+ LfsConfigInvalidException.class,
+ () -> {
+ LfsConnectionFactory.getLfsConnection(db,
+ HttpSupport.METHOD_POST,
+ Protocol.OPERATION_DOWNLOAD);
+ });
+ assertTrue(getStackTrace(actualException)
+ .contains("Invalid line in config file"));
+ }
+ }
+
+ private void addRemoteUrl(String remotUrl) throws Exception {
+ RemoteAddCommand add = git.remoteAdd();
+ add.setUri(new URIish(remotUrl));
+ add.setName(org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME);
+ add.call();
+ }
+
+ /**
+ * Returns the stack trace of the provided exception as string
+ *
+ * @param actualException
+ * @return The exception stack trace as string
+ */
+ private String getStackTrace(Exception actualException) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ actualException.printStackTrace(pw);
+ return sw.toString();
+ }
+
+ private void writeLfsConfig() throws IOException {
+ writeLfsConfig(LFS_SERVER_URL1, "lfs", "url");
+ }
+
+ private void writeLfsConfig(String lfsUrl, String section, String name)
+ throws IOException {
+ writeLfsConfig(lfsUrl, section, null, name);
+ }
+
+ /*
+ * Write simple lfs config with single entry. Do not use FileBasedConfig to
+ * avoid introducing new dependency (for now).
+ */
+ private void writeLfsConfig(String lfsUrl, String section,
+ String subsection, String name) throws IOException {
+ StringBuilder config = new StringBuilder();
+ config.append("[");
+ config.append(section);
+ if (subsection != null) {
+ config.append(" \"");
+ config.append(subsection);
+ config.append("\"");
+ }
+ config.append("]\n");
+ config.append(" ");
+ config.append(name);
+ config.append(" = ");
+ config.append(lfsUrl);
+ writeTrashFile(Constants.DOT_LFS_CONFIG, config.toString());
+ }
+
+ private void writeInvalidLfsConfig() throws IOException {
+ writeTrashFile(Constants.DOT_LFS_CONFIG,
+ "{lfs]\n url = " + LFS_SERVER_URL1);
+ }
+
+ private void checkLfsUrl(String lfsUrl) throws IOException {
+ HttpConnection lfsServerConn;
+ lfsServerConn = LfsConnectionFactory.getLfsConnection(db,
+ HttpSupport.METHOD_POST, Protocol.OPERATION_DOWNLOAD);
+
+ assertEquals(lfsUrl + Protocol.OBJECTS_LFS_ENDPOINT,
+ lfsServerConn.getURL().toString());
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectIdTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectIdTest.java
new file mode 100644
index 0000000000..81c7f14e81
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectIdTest.java
@@ -0,0 +1,564 @@
+/*
+ * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.lfs.lib;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
+import org.junit.Test;
+
+/*
+ * Ported to SHA-256 from org.eclipse.jgit.lib.AbbreviatedObjectIdTest
+ */
+public class AbbreviatedLongObjectIdTest {
+ @Test
+ public void testEmpty_FromByteArray() {
+ final AbbreviatedLongObjectId i;
+ i = AbbreviatedLongObjectId.fromString(new byte[] {}, 0, 0);
+ assertNotNull(i);
+ assertEquals(0, i.length());
+ assertFalse(i.isComplete());
+ assertEquals("", i.name());
+ }
+
+ @Test
+ public void testEmpty_FromString() {
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId
+ .fromString("");
+ assertNotNull(i);
+ assertEquals(0, i.length());
+ assertFalse(i.isComplete());
+ assertEquals("", i.name());
+ }
+
+ @Test
+ public void testFull_FromByteArray() {
+ final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final byte[] b = org.eclipse.jgit.lib.Constants.encodeASCII(s);
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(b,
+ 0, b.length);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertTrue(i.isComplete());
+ assertEquals(s, i.name());
+
+ final LongObjectId f = i.toLongObjectId();
+ assertNotNull(f);
+ assertEquals(LongObjectId.fromString(s), f);
+ assertEquals(f.hashCode(), i.hashCode());
+ }
+
+ @Test
+ public void testFull_FromString() {
+ final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertTrue(i.isComplete());
+ assertEquals(s, i.name());
+
+ final LongObjectId f = i.toLongObjectId();
+ assertNotNull(f);
+ assertEquals(LongObjectId.fromString(s), f);
+ assertEquals(f.hashCode(), i.hashCode());
+ }
+
+ @Test
+ public void test1_FromString() {
+ final String s = "2";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test2_FromString() {
+ final String s = "27";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test3_FromString() {
+ final String s = "27e";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test4_FromString() {
+ final String s = "27e1";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test5_FromString() {
+ final String s = "27e15";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test6_FromString() {
+ final String s = "27e15b";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test7_FromString() {
+ final String s = "27e15b7";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test8_FromString() {
+ final String s = "27e15b72";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test9_FromString() {
+ final String s = "27e15b729";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test15_FromString() {
+ final String s = "27e15b72937fc8f";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test16_FromString() {
+ final String s = "27e15b72937fc8f5";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test17_FromString() {
+ final String s = "27e15b72937fc8f55";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void test33_FromString() {
+ final String s = "27e15b72937fc8f558da24ac3d50ec203";
+ final AbbreviatedLongObjectId i = AbbreviatedLongObjectId.fromString(s);
+ assertNotNull(i);
+ assertEquals(s.length(), i.length());
+ assertFalse(i.isComplete());
+ assertEquals(s, i.name());
+ assertNull(i.toLongObjectId());
+ }
+
+ @Test
+ public void testEquals_Short() {
+ final String s = "27e15b72";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId.fromString(s);
+ final AbbreviatedLongObjectId b = AbbreviatedLongObjectId.fromString(s);
+ assertNotSame(a, b);
+ assertTrue(a.hashCode() == b.hashCode());
+ assertEquals(b, a);
+ assertEquals(a, b);
+ }
+
+ @Test
+ public void testEquals_Full() {
+ final String s = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId.fromString(s);
+ final AbbreviatedLongObjectId b = AbbreviatedLongObjectId.fromString(s);
+ assertNotSame(a, b);
+ assertTrue(a.hashCode() == b.hashCode());
+ assertEquals(b, a);
+ assertEquals(a, b);
+ }
+
+ @Test
+ public void testNotEquals_SameLength() {
+ final String sa = "27e15b72";
+ final String sb = "27e15b7f";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+ final AbbreviatedLongObjectId b = AbbreviatedLongObjectId
+ .fromString(sb);
+ assertFalse(a.equals(b));
+ assertFalse(b.equals(a));
+ }
+
+ @Test
+ public void testNotEquals_DiffLength() {
+ final String sa = "27e15b72abcd";
+ final String sb = "27e15b72";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+ final AbbreviatedLongObjectId b = AbbreviatedLongObjectId
+ .fromString(sb);
+ assertFalse(a.equals(b));
+ assertFalse(b.equals(a));
+ }
+
+ @Test
+ public void testPrefixCompare_Full() {
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(s1);
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b11";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b0f";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testPrefixCompare_1() {
+ final String sa = "2";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "37e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "17e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testPrefixCompare_15() {
+ final String sa = "27e15b72937fc8f";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "27e15b72937fc90558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "27e15b72937fc8e558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testPrefixCompare_16() {
+ final String sa = "27e15b72937fc8f5";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "27e15b72937fc8f658da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "27e15b72937fc8f458da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testPrefixCompare_17() {
+ final String sa = "27e15b72937fc8f55";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "27e15b72937fc8f568da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "27e15b72937fc8f548da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testPrefixCompare_33() {
+ final String sa = "27e15b72937fc8f558da24ac3d50ec203";
+ final AbbreviatedLongObjectId a = AbbreviatedLongObjectId
+ .fromString(sa);
+
+ final String s1 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i1 = LongObjectId.fromString(s1);
+ assertEquals(0, a.prefixCompare(i1));
+ assertTrue(i1.startsWith(a));
+
+ final String s2 = "27e15b72937fc8f558da24ac3d50ec20402a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i2 = LongObjectId.fromString(s2);
+ assertTrue(a.prefixCompare(i2) < 0);
+ assertFalse(i2.startsWith(a));
+
+ final String s3 = "27e15b72937fc8f558da24ac3d50ec20202a4cf21e33b87ae8e4ce90e89c4b10";
+ final LongObjectId i3 = LongObjectId.fromString(s3);
+ assertTrue(a.prefixCompare(i3) > 0);
+ assertFalse(i3.startsWith(a));
+ }
+
+ @Test
+ public void testIsId() {
+ // These are all too short.
+ assertFalse(AbbreviatedLongObjectId.isId(""));
+ assertFalse(AbbreviatedLongObjectId.isId("a"));
+
+ // These are too long.
+ assertFalse(AbbreviatedLongObjectId.isId(LongObjectId
+ .fromString(
+ "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10")
+ .name() + "0"));
+ assertFalse(AbbreviatedLongObjectId.isId(LongObjectId
+ .fromString(
+ "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10")
+ .name() + "c0ffee"));
+
+ // These contain non-hex characters.
+ assertFalse(AbbreviatedLongObjectId.isId("01notahexstring"));
+
+ // These should all work.
+ assertTrue(AbbreviatedLongObjectId.isId("ab"));
+ assertTrue(AbbreviatedLongObjectId.isId("abc"));
+ assertTrue(AbbreviatedLongObjectId.isId("abcd"));
+ assertTrue(AbbreviatedLongObjectId.isId("abcd0"));
+ assertTrue(AbbreviatedLongObjectId.isId("abcd09"));
+ assertTrue(AbbreviatedLongObjectId.isId(LongObjectId
+ .fromString(
+ "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10")
+ .name()));
+ }
+
+ @Test
+ public void testAbbreviate() {
+ AnyLongObjectId id = LongObjectIdTestUtils.hash("test");
+ assertEquals(
+ "abbreviated id should match the id it was abbreviated from", 0,
+ id.abbreviate(10).prefixCompare(id));
+ }
+
+ @Test
+ public void testFromStringByteWrongLength() {
+ byte[] buf = new byte[65];
+ try {
+ AbbreviatedLongObjectId.fromString(buf, 0, 65);
+ fail("expected IllegalArgumentException for too long AbbreviatedLongObjectId");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testFromStringWrongLength() {
+ AnyLongObjectId id = LongObjectIdTestUtils.hash("test");
+ try {
+ AbbreviatedLongObjectId.fromString(id.name() + "c0ffee");
+ fail("expected IllegalArgumentException for too long AbbreviatedLongObjectId");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testFromLongObjectId() {
+ AnyLongObjectId id = LongObjectIdTestUtils.hash("test");
+ assertEquals(0,
+ AbbreviatedLongObjectId.fromLongObjectId(id).prefixCompare(id));
+ }
+
+ @Test
+ public void testPrefixCompareByte() {
+ AnyLongObjectId id = LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
+ byte[] buf = new byte[32];
+ id.copyRawTo(buf, 0);
+
+ AbbreviatedLongObjectId a = id.abbreviate(62);
+ assertEquals(0, a.prefixCompare(buf, 0));
+
+ a = LongObjectId
+ .fromString(
+ "0023456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
+ .abbreviate(16);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef0023456789abcdef0123456789abcdef0123456789abcdef")
+ .abbreviate(32);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef0123456789abcdef0023456789abcdef0123456789abcdef")
+ .abbreviate(48);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0023456789abcdef")
+ .abbreviate(64);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+
+ a = LongObjectId
+ .fromString(
+ "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
+ .abbreviate(16);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef")
+ .abbreviate(32);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef")
+ .abbreviate(48);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = LongObjectId
+ .fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef")
+ .abbreviate(64);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ }
+
+ @Test
+ public void testPrefixCompareLong() {
+ AnyLongObjectId id = new LongObjectId(1L, 2L, 3L, 4L);
+ long[] buf = new long[4];
+ id.copyRawTo(buf, 0);
+
+ AbbreviatedLongObjectId a = id.abbreviate(62);
+ assertEquals(0, a.prefixCompare(buf, 0));
+
+ a = new LongObjectId(0L, 2L, 3L, 4L).abbreviate(16);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 1L, 3L, 4L).abbreviate(32);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 2L, 2L, 4L).abbreviate(48);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 2L, 3L, 3L).abbreviate(64);
+ assertEquals(-1, a.prefixCompare(buf, 0));
+
+ a = new LongObjectId(2L, 2L, 3L, 4L).abbreviate(16);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 3L, 3L, 4L).abbreviate(32);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 2L, 4L, 4L).abbreviate(48);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ a = new LongObjectId(1L, 2L, 3L, 5L).abbreviate(64);
+ assertEquals(1, a.prefixCompare(buf, 0));
+ }
+
+ @Test
+ public void testGetFirstByte() {
+ AnyLongObjectId id = LongObjectId.fromString(
+ "f423456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef");
+ AbbreviatedLongObjectId a = id.abbreviate(10);
+ assertEquals(0xf4, a.getFirstByte());
+ assertEquals(id.getFirstByte(), a.getFirstByte());
+ }
+
+ @SuppressWarnings("unlikely-arg-type")
+ @Test
+ public void testNotEquals() {
+ AbbreviatedLongObjectId a = new LongObjectId(1L, 2L, 3L, 4L)
+ .abbreviate(10);
+ assertFalse(a.equals("different"));
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
new file mode 100644
index 0000000000..da78b28d90
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2016, Christian Halstrick <christian.halstrick@sap.com> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.lfs.lib;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.eclipse.jgit.lfs.LfsPointer;
+import org.junit.Test;
+
+/*
+ * Test LfsPointer file abstraction
+ */
+public class LFSPointerTest {
+
+ private static final String TEST_SHA256 = "27e15b72937fc8f558da24ac3d50ec20302a4cf21e33b87ae8e4ce90e89c4b10";
+
+ @Test
+ public void testEncoding() throws IOException {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer ptr = new LfsPointer(id, 4);
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ ptr.encode(baos);
+ assertEquals(
+ "version https://git-lfs.github.com/spec/v1\noid sha256:"
+ + TEST_SHA256 + "\nsize 4\n",
+ baos.toString(UTF_8.name()));
+ }
+ }
+
+ @Test
+ public void testReadValidLfsPointer() throws Exception {
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "size 4\n";
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertEquals(lfs, LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadValidLfsPointerUnordered() throws Exception {
+ // This is actually not allowed per the spec, but JGit accepts it
+ // anyway.
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "size 4\n"
+ + "oid sha256:" + TEST_SHA256 + '\n';
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertEquals(lfs, LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadValidLfsPointerVersionNotFirst() throws Exception {
+ // This is actually not allowed per the spec, but JGit accepts it
+ // anyway.
+ String ptr = "oid sha256:" + TEST_SHA256 + '\n'
+ + "size 4\n"
+ + "version https://git-lfs.github.com/spec/v1\n";
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertEquals(lfs, LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInvalidLfsPointer() throws Exception {
+ String cSource = "size_t someFunction(void *ptr); // Fake C source\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ cSource.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInvalidLfsPointer2() throws Exception {
+ String cSource = "size_t\nsomeFunction(void *ptr);\n// Fake C source\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ cSource.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInValidLfsPointerVersionWrong() throws Exception {
+ String ptr = "version https://git-lfs.example.org/spec/v1\n"
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "size 4\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInValidLfsPointerVersionTwice() throws Exception {
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "size 4\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInValidLfsPointerVersionTwice2() throws Exception {
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "version https://git-lfs.github.com/spec/v1\n"
+ + "size 4\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInValidLfsPointerOidTwice() throws Exception {
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "oid sha256:" + TEST_SHA256 + '\n'
+ + "size 4\n";
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testReadInValidLfsPointerSizeTwice() throws Exception {
+ String ptr = "version https://git-lfs.github.com/spec/v1\n"
+ + "size 4\n"
+ + "size 4\n"
+ + "oid sha256:" + TEST_SHA256 + '\n';
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ ptr.getBytes(UTF_8))) {
+ assertNull("Is not a LFS pointer", LfsPointer.parseLfsPointer(in));
+ }
+ }
+
+ @Test
+ public void testRoundtrip() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer ptr = new LfsPointer(id, 4);
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ ptr.encode(baos);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(
+ baos.toByteArray())) {
+ assertEquals(ptr, LfsPointer.parseLfsPointer(in));
+ }
+ }
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 4);
+ assertTrue(lfs.equals(lfs2));
+ assertTrue(lfs2.equals(lfs));
+ }
+
+ @Test
+ public void testEqualsNull() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertFalse(lfs.equals(null));
+ }
+
+ @Test
+ public void testEqualsSame() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertTrue(lfs.equals(lfs));
+ }
+
+ @Test
+ public void testEqualsOther() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertFalse(lfs.equals(new Object()));
+ }
+
+ @Test
+ public void testNotEqualsOid() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId
+ .fromString(TEST_SHA256.replace('7', '5'));
+ LfsPointer lfs2 = new LfsPointer(id2, 4);
+ assertFalse(lfs.equals(lfs2));
+ assertFalse(lfs2.equals(lfs));
+ }
+
+ @Test
+ public void testNotEqualsSize() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 5);
+ assertFalse(lfs.equals(lfs2));
+ assertFalse(lfs2.equals(lfs));
+ }
+
+ @Test
+ public void testCompareToEquals() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 4);
+ assertEquals(0, lfs.compareTo(lfs2));
+ assertEquals(0, lfs2.compareTo(lfs));
+ }
+
+ @Test
+ @SuppressWarnings("SelfComparison")
+ public void testCompareToSame() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertEquals(0, lfs.compareTo(lfs));
+ }
+
+ @Test
+ public void testCompareToNotEqualsOid() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId
+ .fromString(TEST_SHA256.replace('7', '5'));
+ LfsPointer lfs2 = new LfsPointer(id2, 4);
+ assertNotEquals(0, lfs.compareTo(lfs2));
+ assertNotEquals(0, lfs2.compareTo(lfs));
+ }
+
+ @Test
+ public void testCompareToNotEqualsSize() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 5);
+ assertNotEquals(0, lfs.compareTo(lfs2));
+ assertNotEquals(0, lfs2.compareTo(lfs));
+ }
+
+ @Test
+ public void testCompareToNull() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertThrows(NullPointerException.class, () -> lfs.compareTo(null));
+ }
+
+ @Test
+ public void testHashcodeEquals() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 4);
+ assertEquals(lfs.hashCode(), lfs2.hashCode());
+ }
+
+ @Test
+ public void testHashcodeSame() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ assertEquals(lfs.hashCode(), lfs.hashCode());
+ }
+
+ @Test
+ public void testHashcodeNotEquals() throws Exception {
+ AnyLongObjectId id = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs = new LfsPointer(id, 4);
+ AnyLongObjectId id2 = LongObjectId.fromString(TEST_SHA256);
+ LfsPointer lfs2 = new LfsPointer(id2, 5);
+ assertNotEquals(lfs.hashCode(), lfs2.hashCode());
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LfsPointerFilterTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LfsPointerFilterTest.java
new file mode 100644
index 0000000000..081a4a50a4
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LfsPointerFilterTest.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2015, Dariusz Luksza <dariusz@luksza.org> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.lfs.lib;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
+import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
+import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.revwalk.ObjectWalk;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevTree;
+import org.eclipse.jgit.treewalk.TreeWalk;
+import org.junit.Test;
+
+public class LfsPointerFilterTest {
+
+ private static final int SIZE = 12345;
+
+ private static final String OID = "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393";
+
+ private static final String[] NOT_VALID_LFS_FILES = { "", // empty file
+ // simulate java file
+ "package org.eclipse.jgit;",
+ // invalid LFS pointer, no oid and version
+ "version https://hawser.github.com/spec/v1\n",
+ // invalid LFS pointer, no version
+ "version https://hawser.github.com/spec/v1\n"
+ + "oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\n",
+ // invalid LFS pointer, no id
+ "version https://hawser.github.com/spec/v1\n" + "size 12345\n",
+ // invalid LFS pointer, wrong order of oid and size
+ "version https://hawser.github.com/spec/v1\n" + "size 12345\n"
+ + "oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\n" };
+
+ private static final String[] LFS_VERSION_DOMAINS = {
+ "hawser", "git-lfs"
+ };
+
+ private static final String[] VALID_LFS_FILES = {
+ // valid LFS pointer
+ "version https://%s.github.com/spec/v1\n"
+ + "oid sha256:" + OID + "\n"
+ + "size " + SIZE + "\n",
+ // valid LFS pointer with "custom" key
+ "version https://%s.github.com/spec/v1\n"
+ + "custom key with value\n"
+ + "oid sha256:" + OID + "\n"
+ + "size " + SIZE + "\n",
+ // valid LFS pointer with key with "."
+ "version https://%s.github.com/spec/v1\n"
+ + "oid sha256:" + OID + "\n"
+ + "r.key key with .\n"
+ + "size " + SIZE + "\n",
+ // valid LFS pointer with key with "-"
+ "version https://%s.github.com/spec/v1\n"
+ + "oid sha256:" + OID + "\n"
+ + "size " + SIZE + "\n"
+ + "valid-name another valid key\n" };
+
+ @Test
+ public void testRegularFilesInRepositoryRoot() throws Exception {
+ for (String file : NOT_VALID_LFS_FILES) {
+ assertLfs("file.bin", file).withRecursive(false).shouldBe(false);
+ }
+ }
+
+ @Test
+ public void testNestedRegularFiles() throws Exception {
+ for (String file : NOT_VALID_LFS_FILES) {
+ assertLfs("a/file.bin", file).withRecursive(true).shouldBe(false);
+ }
+ }
+
+ @Test
+ public void testValidPointersInRepositoryRoot() throws Exception {
+ for (String domain : LFS_VERSION_DOMAINS) {
+ for (String file : VALID_LFS_FILES) {
+ assertLfs("file.bin", String.format(file, domain))
+ .withRecursive(true).shouldBe(true)
+ .check();
+ }
+ }
+ }
+
+ @Test
+ public void testValidNestedPointers() throws Exception {
+ for (String domain : LFS_VERSION_DOMAINS) {
+ for (String file : VALID_LFS_FILES) {
+ assertLfs("a/file.bin", String.format(file, domain))
+ .withRecursive(true).shouldBe(true).check();
+ }
+ }
+ }
+
+ @Test
+ public void testValidNestedPointersWithoutRecurrence() throws Exception {
+ for (String domain : LFS_VERSION_DOMAINS) {
+ for (String file : VALID_LFS_FILES) {
+ assertLfs("file.bin", String.format(file, domain))
+ .withRecursive(false).shouldBe(true).check();
+ assertLfs("a/file.bin", String.format(file, domain))
+ .withRecursive(false).shouldBe(false).check();
+ }
+ }
+ }
+
+ private static LfsTreeWalk assertLfs(String path, String content) {
+ return new LfsTreeWalk(path, content);
+ }
+
+ private static class LfsTreeWalk {
+ private final String path;
+
+ private final String content;
+
+ private boolean state;
+
+ private boolean recursive;
+
+ private TestRepository<InMemoryRepository> tr;
+
+ LfsTreeWalk(String path, String content) {
+ this.path = path;
+ this.content = content;
+ }
+
+ LfsTreeWalk withRecursive(boolean shouldBeRecursive) {
+ this.recursive = shouldBeRecursive;
+ return this;
+ }
+
+ LfsTreeWalk shouldBe(boolean shouldBeValid) {
+ this.state = shouldBeValid;
+ return this;
+ }
+
+ void check() throws Exception {
+ tr = new TestRepository<>(new InMemoryRepository(
+ new DfsRepositoryDescription("test")));
+ RevCommit commit = tr.branch("master").commit().add(path, content)
+ .message("initial commit").create();
+ RevTree tree = parseCommit(commit);
+ LfsPointerFilter filter = new LfsPointerFilter();
+ try (TreeWalk treeWalk = new TreeWalk(tr.getRepository())) {
+ treeWalk.addTree(tree);
+ treeWalk.setRecursive(recursive);
+ treeWalk.setFilter(filter);
+
+ if (state) {
+ assertTrue(treeWalk.next());
+ assertEquals(path, treeWalk.getPathString());
+ assertNotNull(filter.getPointer());
+ assertEquals(SIZE, filter.getPointer().getSize());
+ assertEquals(OID, filter.getPointer().getOid().name());
+ } else {
+ assertFalse(treeWalk.next());
+ assertNull(filter.getPointer());
+ }
+ }
+ }
+
+ private RevTree parseCommit(RevCommit commit) throws Exception {
+ try (ObjectWalk ow = new ObjectWalk(tr.getRepository())) {
+ return ow.parseCommit(commit).getTree();
+ }
+ }
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java
new file mode 100644
index 0000000000..a71d42367d
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.lfs.lib;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Locale;
+
+import org.eclipse.jgit.junit.JGitTestUtil;
+import org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException;
+import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils;
+import org.eclipse.jgit.util.FileUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/*
+ * Ported to SHA-256 from org.eclipse.jgit.lib.ObjectIdTest
+ */
+public class LongObjectIdTest {
+ private static Path tmp;
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ tmp = Files.createTempDirectory("jgit_test_");
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException {
+ FileUtils.delete(tmp.toFile(), FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
+
+ @Test
+ public void test001_toString() {
+ final String x = "8367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2deb7ab0a";
+ final LongObjectId oid = LongObjectId.fromString(x);
+ assertEquals(x, oid.name());
+ }
+
+ @Test
+ public void test002_toString() {
+ final String x = "140ce71d628cceb78e3709940ba52a651a0c4a9c1400f2e15e998a1a43887edf";
+ final LongObjectId oid = LongObjectId.fromString(x);
+ assertEquals(x, oid.name());
+ }
+
+ @Test
+ public void test003_equals() {
+ final String x = "8367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2deb7ab0a";
+ final LongObjectId a = LongObjectId.fromString(x);
+ final LongObjectId b = LongObjectId.fromString(x);
+ assertEquals(a.hashCode(), b.hashCode());
+ assertEquals("a and b should be equal", b, a);
+ }
+
+ @Test
+ public void test004_isId() {
+ assertTrue("valid id", LongObjectId.isId(
+ "8367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2deb7ab0a"));
+ }
+
+ @Test
+ public void test005_notIsId() {
+ assertFalse("bob is not an id", LongObjectId.isId("bob"));
+ }
+
+ @Test
+ public void test006_notIsId() {
+ assertFalse("63 digits is not an id", LongObjectId.isId(
+ "8367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2deb7ab0"));
+ }
+
+ @Test
+ public void test007_isId() {
+ assertTrue("uppercase is accepted", LongObjectId.isId(
+ "8367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2dEb7ab0A"));
+ }
+
+ @Test
+ public void test008_notIsId() {
+ assertFalse("g is not a valid hex digit", LongObjectId.isId(
+ "g367b0edc81df80e6b42eb1b71f783111224e058cb3da37894d065d2deb7ab0a"));
+ }
+
+ @Test
+ public void test009_toString() {
+ final String x = "140ce71d628cceb78e3709940ba52a651a0c4a9c1400f2e15e998a1a43887edf";
+ final LongObjectId oid = LongObjectId.fromString(x);
+ assertEquals(x, LongObjectId.toString(oid));
+ }
+
+ @Test
+ public void test010_toString() {
+ final String x = "0000000000000000000000000000000000000000000000000000000000000000";
+ assertEquals(x, LongObjectId.toString(null));
+ }
+
+ @Test
+ public void test011_toString() {
+ final String x = "0123456789ABCDEFabcdef01234567890123456789ABCDEFabcdef0123456789";
+ final LongObjectId oid = LongObjectId.fromString(x);
+ assertEquals(x.toLowerCase(Locale.ROOT), oid.name());
+ }
+
+ @Test
+ public void testGetByte() {
+ byte[] raw = new byte[32];
+ for (int i = 0; i < 32; i++)
+ raw[i] = (byte) (0xa0 + i);
+ LongObjectId id = LongObjectId.fromRaw(raw);
+
+ assertEquals(raw[0] & 0xff, id.getFirstByte());
+ assertEquals(raw[0] & 0xff, id.getByte(0));
+ assertEquals(raw[1] & 0xff, id.getByte(1));
+ assertEquals(raw[1] & 0xff, id.getSecondByte());
+
+ for (int i = 2; i < 32; i++) {
+ assertEquals("index " + i, raw[i] & 0xff, id.getByte(i));
+ }
+ try {
+ id.getByte(32);
+ fail("LongObjectId has 32 byte only");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testSetByte() {
+ byte[] exp = new byte[32];
+ for (int i = 0; i < 32; i++) {
+ exp[i] = (byte) (0xa0 + i);
+ }
+
+ MutableLongObjectId id = new MutableLongObjectId();
+ id.fromRaw(exp);
+ assertEquals(LongObjectId.fromRaw(exp).name(), id.name());
+
+ id.setByte(0, 0x10);
+ assertEquals(0x10, id.getByte(0));
+ exp[0] = 0x10;
+ assertEquals(LongObjectId.fromRaw(exp).name(), id.name());
+
+ for (int p = 1; p < 32; p++) {
+ id.setByte(p, 0x10 + p);
+ assertEquals(0x10 + p, id.getByte(p));
+ exp[p] = (byte) (0x10 + p);
+ assertEquals(LongObjectId.fromRaw(exp).name(), id.name());
+ }
+
+ for (int p = 0; p < 32; p++) {
+ id.setByte(p, 0x80 + p);
+ assertEquals(0x80 + p, id.getByte(p));
+ exp[p] = (byte) (0x80 + p);
+ assertEquals(LongObjectId.fromRaw(exp).name(), id.name());
+ }
+ }
+
+ @Test
+ public void testZeroId() {
+ AnyLongObjectId zero = new LongObjectId(0L, 0L, 0L, 0L);
+ assertEquals(zero, LongObjectId.zeroId());
+ assertEquals(
+ "0000000000000000000000000000000000000000000000000000000000000000",
+ LongObjectId.zeroId().name());
+ }
+
+ @Test
+ public void testEquals() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ assertTrue("id should equal itself", id1.equals(id1));
+ AnyLongObjectId id2 = new LongObjectId(id1);
+ assertEquals("objects should be equals", id1, id2);
+
+ id2 = LongObjectIdTestUtils.hash("other");
+ assertNotEquals("objects should be not equal", id1, id2);
+ }
+
+ @Test
+ public void testCopyRawBytes() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ AnyLongObjectId id2 = new LongObjectId(id1);
+
+ byte[] buf = new byte[64];
+ id1.copyRawTo(buf, 0);
+ id2.copyRawTo(buf, 32);
+ assertTrue("objects should be equals",
+ LongObjectId.equals(buf, 0, buf, 32));
+ }
+
+ @Test
+ public void testCopyRawLongs() {
+ long[] a = new long[4];
+ a[0] = 1L;
+ a[1] = 2L;
+ a[2] = 3L;
+ a[3] = 4L;
+ AnyLongObjectId id1 = new LongObjectId(a[0], a[1], a[2], a[3]);
+ AnyLongObjectId id2 = LongObjectId.fromRaw(a);
+ assertEquals("objects should be equals", id1, id2);
+ }
+
+ @Test
+ public void testCopyFromStringInvalid() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ try {
+ LongObjectId.fromString(id1.name() + "01234");
+ fail("expected InvalidLongObjectIdException");
+ } catch (InvalidLongObjectIdException e) {
+ assertEquals("Invalid id: " + id1.name() + "01234",
+ e.getMessage());
+ }
+ }
+
+ @Test
+ public void testCopyFromStringByte() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ byte[] buf = new byte[64];
+ Charset cs = US_ASCII;
+ cs.encode(id1.name()).get(buf);
+ AnyLongObjectId id2 = LongObjectId.fromString(buf, 0);
+ assertEquals("objects should be equals", id1, id2);
+ }
+
+ @Test
+ public void testHashFile() throws IOException {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ Path f = tmp.resolve("test");
+ JGitTestUtil.write(f.toFile(), "test");
+ AnyLongObjectId id2 = LongObjectIdTestUtils.hash(f);
+ assertEquals("objects should be equals", id1, id2);
+ }
+
+ @Test
+ public void testCompareTo() {
+ AnyLongObjectId id1 = LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
+ assertEquals(0, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")));
+ AnyLongObjectId self = id1;
+ assertEquals(0, id1.compareTo(self));
+
+ assertEquals(-1, id1.compareTo(LongObjectId.fromString(
+ "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")));
+ assertEquals(-1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef")));
+ assertEquals(-1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef")));
+ assertEquals(-1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef")));
+
+ assertEquals(1, id1.compareTo(LongObjectId.fromString(
+ "0023456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")));
+ assertEquals(1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0023456789abcdef0123456789abcdef0123456789abcdef")));
+ assertEquals(1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0023456789abcdef0123456789abcdef")));
+ assertEquals(1, id1.compareTo(LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0023456789abcdef")));
+ }
+
+ @Test
+ public void testCompareToByte() {
+ AnyLongObjectId id1 = LongObjectId.fromString(
+ "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
+ byte[] buf = new byte[32];
+ id1.copyRawTo(buf, 0);
+ assertEquals(0, id1.compareTo(buf, 0));
+
+ LongObjectId
+ .fromString(
+ "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
+ .copyRawTo(buf, 0);
+ assertEquals(-1, id1.compareTo(buf, 0));
+
+ LongObjectId
+ .fromString(
+ "0023456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
+ .copyRawTo(buf, 0);
+ assertEquals(1, id1.compareTo(buf, 0));
+ }
+
+ @Test
+ public void testCompareToLong() {
+ AnyLongObjectId id1 = new LongObjectId(1L, 2L, 3L, 4L);
+ long[] buf = new long[4];
+ id1.copyRawTo(buf, 0);
+ assertEquals(0, id1.compareTo(buf, 0));
+
+ new LongObjectId(2L, 2L, 3L, 4L).copyRawTo(buf, 0);
+ assertEquals(-1, id1.compareTo(buf, 0));
+
+ new LongObjectId(0L, 2L, 3L, 4L).copyRawTo(buf, 0);
+ assertEquals(1, id1.compareTo(buf, 0));
+ }
+
+ @Test
+ public void testCopyToByte() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ byte[] buf = new byte[64];
+ id1.copyTo(buf, 0);
+ assertEquals(id1, LongObjectId.fromString(buf, 0));
+ }
+
+ @Test
+ public void testCopyRawToByteBuffer() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteBuffer buf = ByteBuffer.allocate(32);
+ id1.copyRawTo(buf);
+ assertEquals(id1, LongObjectId.fromRaw(buf.array(), 0));
+ }
+
+ @Test
+ public void testCopyToByteBuffer() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteBuffer buf = ByteBuffer.allocate(64);
+ id1.copyTo(buf);
+ assertEquals(id1, LongObjectId.fromString(buf.array(), 0));
+ }
+
+ @Test
+ public void testCopyRawToOutputStream() throws IOException {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteArrayOutputStream os = new ByteArrayOutputStream(32);
+ id1.copyRawTo(os);
+ assertEquals(id1, LongObjectId.fromRaw(os.toByteArray(), 0));
+ }
+
+ @Test
+ public void testCopyToOutputStream() throws IOException {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteArrayOutputStream os = new ByteArrayOutputStream(64);
+ id1.copyTo(os);
+ assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
+ }
+
+ @Test
+ public void testCopyToWriter() throws IOException {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteArrayOutputStream os = new ByteArrayOutputStream(64);
+ try (OutputStreamWriter w = new OutputStreamWriter(os,
+ UTF_8)) {
+ id1.copyTo(w);
+ }
+ assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
+ }
+
+ @Test
+ public void testCopyToWriterWithBuf() throws IOException {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ ByteArrayOutputStream os = new ByteArrayOutputStream(64);
+ try (OutputStreamWriter w = new OutputStreamWriter(os,
+ UTF_8)) {
+ char[] buf = new char[64];
+ id1.copyTo(buf, w);
+ }
+ assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
+ }
+
+ @Test
+ public void testCopyToStringBuilder() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ StringBuilder sb = new StringBuilder();
+ char[] buf = new char[64];
+ id1.copyTo(buf, sb);
+ assertEquals(id1, LongObjectId.fromString(sb.toString()));
+ }
+
+ @Test
+ public void testCopy() {
+ AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
+ assertEquals(id1.copy(), id1);
+ MutableLongObjectId id2 = new MutableLongObjectId();
+ id2.fromObjectId(id1);
+ assertEquals(id1, id2.copy());
+ }
+}
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/MutableLongObjectIdTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/MutableLongObjectIdTest.java
new file mode 100644
index 0000000000..8c19cd714f
--- /dev/null
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/MutableLongObjectIdTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.lfs.lib;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/*
+ * Ported to SHA-256 from org.eclipse.jgit.lib.MutableObjectIdTest
+ */
+public class MutableLongObjectIdTest {
+
+ @Test
+ public void testFromRawLong() {
+ MutableLongObjectId m = new MutableLongObjectId();
+ m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
+ assertEquals(new LongObjectId(1L, 2L, 3L, 4L), m);
+ }
+
+ @Test
+ public void testFromString() {
+ AnyLongObjectId id = new LongObjectId(1L, 2L, 3L, 4L);
+ MutableLongObjectId m = new MutableLongObjectId();
+ m.fromString(id.name());
+ assertEquals(id, m);
+ }
+
+ @Test
+ public void testFromStringByte() {
+ AnyLongObjectId id = new LongObjectId(1L, 2L, 3L, 4L);
+ MutableLongObjectId m = new MutableLongObjectId();
+ byte[] buf = new byte[64];
+ id.copyTo(buf, 0);
+ m.fromString(buf, 0);
+ assertEquals(id, m);
+ }
+
+ @Test
+ public void testCopy() {
+ MutableLongObjectId m = new MutableLongObjectId();
+ m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
+ assertEquals(m, new MutableLongObjectId(m));
+ }
+
+ @Test
+ public void testToObjectId() {
+ MutableLongObjectId m = new MutableLongObjectId();
+ m.fromRaw(new long[] { 1L, 2L, 3L, 4L });
+ assertEquals(m, m.toObjectId());
+ }
+}