Problem occurs when the checkout wants to create a file 'd/f' but
the workingtree contains a dirty file 'd'. In order to create d/f the
file 'd' would have to be deleted and since the file is dirty that
content would be lost. This should lead to a CheckoutConflictException
for d/f when failOnConflict was set to true.
This fix also changes jgit checkout semantics to be more like native
gits checkout semantics. If during a checkout jgit wants to delete a
folder but finds that the working tree contains a dirty file at this
path then JGit will now throw an exception instead of silently keeping
the dirty file. Like in this example:
git init
touch b
git add b
git commit -m addB
mkdir a
touch a/c
git add a/c
git commit -m addAC
rm -fr a
touch a
git checkout HEAD~
Change-Id: I9089123179e09dd565285d50b0caa308d290cccd
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Also-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
With this change it is possible to initialize repositories with
'git init /path/to/new/repo'
Change-Id: Ia9b288b4fb34887e8f5e2f3f270e521c44d41b6a
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Allocate a new Git for each part of the test, rather than
reassigning to the same variable.
Change-Id: Ic83778bbff0b2f57d37b95aef70324859d42cd58
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Currently execution of tests in pgm uses CLIGitCommand which
re-implements few things from Main. Unfortunately this can results in a
different test behavior compared to the real CLI runtime.
The change let CLIGitCommand extend Main and only slightly modifies the
runtime (stream redirection and undesired exit() termination).
Change-Id: I87b7b61d1c84a89e5917610d84409f01be90b70b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
git branch -d -h reports an error (because of missing -d option value)
but does not print the help as expected.
To fix this, CmdLineParser must catch, print but do not propagate
exceptions if help is requested.
Bug: 484951
Change-Id: I51265ebe295f22da540792c6a1980b8bdb295a02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
In different places (Main, TextBuiltin, CLIGitCommand) we report fatal
errors and at same time want to check for fatal errors in the tests.
Using common API simplifies the error testing and helps to navigate to
the actual error check implementation.
Change-Id: Iecde79beb33ea595171f168f46b0b10ab2f339bb
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Maven pom files force the local encoding to UTF-8 to ensure there are
no differences between machines. They also set the JVM max heap to
256m. Match both in Buck so that results are consistent.
Change-Id: Ice5476dd09352a444a0c97aa0dc28806fddf2ab4
Compile each test in its own java_test() target so they can run in
parallel, reducing total time spent testing on large machines.
$ buck test --all
[-] PROCESSING BUCK FILES...FINISHED 0.3s [100%]
[-] BUILDING...FINISHED 2.9s [100%] (351/383 JOBS, 351 UPDATED, 0.0% CACHE MISS)
[-] TESTING...FINISHED 98.1s (3360 PASS/15 SKIP/0 FAIL)
Change-Id: I8d6541268315089299f933ed23d785b1b3431133
Make the default execute() function fail fast on first command printed
"fatal: " to output.
Introduced executeUnchecked() for few tests which wanted to test fatal
output.
Change-Id: I5b09aad9443515636811fc4d00bf8b8b9587a626
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
The "--" path option (and all other similar options consuming all
remaining arguments) should be placed at the end of the command line
help.
Currently jgit reset -h shows this:
jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard]
[--help (-h)] [--mixed] [--soft]
After the patch the help shows this:
jgit reset [commit-ish] [path ... ...] [--hard] [--help (-h)] [--mixed]
[--soft] [-- path ... ...]
Bug: 484951
Change-Id: I3db332bf293ca8d6bfaab0d546cd35af689bd46e
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This commit changes the jgit "reset" command line options help from
this:
jgit reset name [VAL ...] [-- path ... ...] [--hard] [--help (-h)]
[--mixed] [--soft]
name : Reset current HEAD to the specified state
[...]
to this:
jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard]
[--help (-h)] [--mixed] [--soft]
commit-ish : Reset to given reference name
[...]
Bug: 484951
Change-Id: I614e71101b4f9f46ef8f02379d1a9d135f3292d2
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This fixes the command below:
jgit commit a -m "added file a"
which currently fails with:
org.eclipse.jgit.api.errors.JGitInternalException: The combination of
arguments --all and --only is not allowed
Bug: 484973
Change-Id: I37a4ccd68101a66520ef99110f7aa0cbdcc8beba
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Fixes point 4 in bug 484951, where "jgit repo" or "jgit repo -h" dumps a
stack trace.
Bug: 484951
Change-Id: Ic8b362e07a40ad923dc9acde0c0983a1e7932a02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signal early command termination due '-h' or '--help' option via
TerminatedByHelpException. This allows tests using
CLIGitCommand differentiate between unexpected command parsing errors
and expected command cancellation "on help" (which also allows
validation of expected/unexpected help messages).
Additional side-effect: jgit supports now git style of handling help
option: any unexpected command line options before help are reported as
errors, but after help ignored.
Bug: 484951
Change-Id: If45c41c0d32895ab6822a7ff9d851877dcef5771
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This will execute git commands (with arguments) specified on the command
line, handy for developing/debugging a sequence of arbitrary git
commands working on same repository.
The git working dir path can be specified via Java system property
"git_work_tree". If not specified, current directory will be used.
Change-Id: I621a9ec198c31e28a383818efeb4b3f835ba1d6f
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>