Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Extend DirCacheCheckout to skip conflicts

My understanding, in this case, is that a CheckoutConflictException should only be thrown if setFailOnConflict() was set to true. Otherwise, the local file f should be overridden like it is the case in other conflict situations. Or am I missing something here?



From: Christian Halstrick <christian.halstrick@xxxxxxxxx>
To: R�diger Herrmann <ruediger.herrmann@xxxxxx>
Sent: Tuesday, June 14, 2016 4:32 PM
Subject: Re: [jgit-dev] Extend DirCacheCheckout to skip conflicts

Right, I think we should throw a CheckoutConflictException instead of
the IOException which we currently throw. Good catch.

The checkout which you try needs to update the file f/a. But we can't
update f/a because there is a local file f which contains untracked
data. And overwriting unsaved data without asking the user is a no-go.
I checked native git and also native git see's a checkout conflict in
this case:

> git init
Initialized empty Git repository in /tmp/yy/.git/
> mkdir f
> echo 1 >f/a
> git add f/a
> git commit -m "add f/a"
[master (root-commit) 0597257] add f/a
1 file changed, 1 insertion(+)
create mode 100644 f/a
> git checkout -b side
Switched to a new branch 'side'
> echo 2 >f/a
> git commit -a -m "modify f/a on side"
[side 817b229] modify f/a on side
1 file changed, 1 insertion(+), 1 deletion(-)
> git checkout master
Switched to branch 'master'
> rm -fr f
> echo 3 >f
> git checkout side
error: Your local changes to the following files would be overwritten
by checkout:
f/a
Please, commit your changes or stash them before you can switch branches.
Aborting

Ciao
  Chris


On Sun, Jun 12, 2016 at 3:50 PM, R�diger Herrmann
<ruediger.herrmann@xxxxxx> wrote:
> while reworking the draft patch, I think I've found a bug that is unrelated
> to skipping conflicts. Could you run this snippet within the
> DirCacheCheckoutTest?
>
> @Test
> public void testSkipConflictsWithFolderFileConflict() throws Exception {
> RevCommit headCommit = commitFile("f/a", "initial content", "master");
> RevCommit checkoutCommit = commitFile("f/a", "side content", "side");
> FileUtils.delete(new File(db.getWorkTree(), "f"), RECURSIVE);
> writeTrashFile("f", "file instead of folder");
>
> dco = new DirCacheCheckout(db, headCommit.getTree(), db.lockDirCache(),
> checkoutCommit.getTree());
> boolean checkoutOk = dco.checkout();
>
> assertTrue(checkoutOk);
> }
>
> The outcome should probably be a CheckoutConflictException or silently
> override file 'f' depending on setFailOnConfict().
>
> - Rüdiger
>
> From: Matthias Sohn <matthias.sohn@xxxxxxxxx>
> To: R�diger Herrmann <ruediger.herrmann@xxxxxx>
> Cc: JGit Developers List <jgit-dev@xxxxxxxxxxx>
> Sent: Thursday, June 9, 2016 8:53 PM
>
> Subject: Re: [jgit-dev] Extend DirCacheCheckout to skip conflicts
>
> sounds good
>
> On Thu, Jun 9, 2016 at 5:57 PM, R�diger Herrmann <ruediger.herrmann@xxxxxx>
> wrote:
>
> Hi,
>
> thanks for your feedback. The use case for this extension is to more easily
> deal with conflicting checkouts in a Git GUI tool. Currently, either the
> whole operation is rejected or it will override/delete all conflicting work
> directory entries, With a partially checked out conflicting commit where
> only the conflicting files are not checked out, users should be able to
> resolve the remaining conflicts in a compare/synchronize view if necessary.
>
> The workflow could be something like this:
> 1. user attempts to check out commit x
> 2. the tool figures out that there are conflicts and asks to check out all
> non-conflicting files
> 3. if the user agrees, the tool provides a compare/synchronize UI to resolve
> the remaining conflicts
>
> If you agree, I will work on the comments you gave and upload another patch
> for review.
>
> Best,
> Rüdiger
>
>
> ________________________________
> From: Matthias Sohn <matthias.sohn@xxxxxxxxx>
> To: R�diger Herrmann <ruediger.herrmann@xxxxxx>
> Cc: JGit Developers List <jgit-dev@xxxxxxxxxxx>
> Sent: Thursday, June 9, 2016 9:39 AM
> Subject: Re: [jgit-dev] Extend DirCacheCheckout to skip conflicts
>
> On Tue, Jun 7, 2016 at 7:36 PM, R�diger Herrmann <ruediger.herrmann@xxxxxx>
> wrote:
>
> Dear JGit developers,
>
> I would like to extend the DirCacheCheckout so that it skips conflicting
> files during checkout. Given, the new property _skipConflicts_ is set to
> true, a conflicting file in the work directory would remain untouched. The
> entire checkout operation would be considered successful and getConflicts()
> would return the conflicting (not checked out) files.
>
> To better illustrate what the change is about, I have uploaded a draft patch
> to Gerrit:
https://git.eclipse.org/r/74814 [draft] Extend DirCacheCheckout to skip
> conflicting files
>
> Would you consider such an enhancement as generally useful and accept a
> patch therefore?
>
>
> sounds like a reasonable enhancement, I added comments on your change
>
> -Matthias
>
>
>
> _______________________________________________
> jgit-dev mailing list
> jgit-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jgit-dev
>
>
>
>
>
> _______________________________________________
> jgit-dev mailing list
> jgit-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/jgit-dev



Back to the top