defects4j icon indicating copy to clipboard operation
defects4j copied to clipboard

Error When Checkout Json

Open neelofarhassan opened this issue 3 years ago • 14 comments

I am getting this error while checking out Json versions. I made sure that I don't have any local changes in the repository, I tried checking out whole defects4j repository and initialize it from scratch, but same error. Could someone please suggest what's wrong with this?

Thanks Neelofar

Checking out 27a52f90 to /data/scratch/projects/punim1163/software-testing/ FAIL Executed command: git clone /home/nneelofar/defects4j/project_repos/jsoup.git /data/scratch/projects/punim1163/software-testing/fault-localization/defects4j-data-test-properties/Jsoup/data/1-Jsoup-evosuite/Jsoup-1f 2>&1 && cd /data/scratch/projects/punim1163/software-testing/fault-localization/defects4j-data-test-properties/Jsoup/data/1-Jsoup-evosuite/Jsoup-1f && git checkout 27a52f90a25699bebe23ff1ff94d6db361fdb11d 2>&1 Cloning into '/data/scratch/projects/punim1163/software-testing/fault-localization/defects4j-data-test-properties/Jsoup/data/1-Jsoup-evosuite/Jsoup-1f'... done. error: Your local changes to the following files would be overwritten by checkout: src/test/java/org/jsoup/parser/TokeniserStateTest.java Please, commit your changes or stash them before you can switch branches. Aborting Cannot checkout program version! at /home/nneelofar/defects4j/framework/bin/d4j/d4j-checkout line 96. Compilation failed in require at /home/nneelofar/defects4j/framework/bin/defects4j line 195.

neelofarhassan avatar Aug 27 '20 02:08 neelofarhassan

Hi @neelofarhassan,

Unfortunately, I cannot replicate this error.

As a simple sanity check, I would recommend clearing a directory before running a second defects4j checkout command. If you run any sort of compilation/test execution, it can introduce side effects when you perform a different checkout of the same project.

Greg4cr avatar Aug 27 '20 09:08 Greg4cr

Thank you @Greg4cr for your reply, The command I am using to checkout any of the Jsoup fixed version is defects4j checkout -p Jsoup -v 1f -w Jsoup-1f Sorry I couldn't understand what second checkout command you suggested?

Furthermore, exactly the same command for other projects checkout buggy/fixed versions and later generate tests and mutants successfully.

neelofarhassan avatar Aug 27 '20 12:08 neelofarhassan

What I mean is that you should clear (rm -rf Jsoup-1f/*) the contents of the directory you checkout into (in this case Jsoup-1f) before you use defects4j checkout a second time.

Running defects4j checkout -p Jsoup -v 1f -w Jsoup-1f works for me if Jsoup-1f is an empty directory.

Greg4cr avatar Aug 27 '20 12:08 Greg4cr

Thanks @Greg4cr, I am making sure that the directory is empty before checking out the project. As you can't reproduce the bug, I will try to find if this is something related to my system settings. Thanks

neelofarhassan avatar Aug 27 '20 12:08 neelofarhassan

Hi, @neelofarhassan. I'm in the same trouble. Can not checkout for the 1-83 versions of Jsoup. But other projects/versions is fine. Is my configuration wrong?

47attribute avatar Feb 04 '21 10:02 47attribute

Hi @47attribute, can you share any information on how you are checking out the bug? (e.g., the commands used, scripting surrounding those commands, are you clearing the directory before checking out?, operating system used)

Are you seeing the same error as @neelofarhassan? error: Your local changes to the following files would be overwritten by checkout

Greg4cr avatar Feb 04 '21 10:02 Greg4cr

My system is Ubuntu 16.04.7 LTS. The commands and error info are following ( Just Jsoup1-81) Pic

47attribute avatar Feb 04 '21 10:02 47attribute

Thanks @47attribute. I'll look at it when I get a little time and see if I can figure out a reason (and why it works for some people).

Greg4cr avatar Feb 04 '21 10:02 Greg4cr

I'm also running into this problem, where checkout for Jsoup works in some environments and fails in others. It seems, in the instances it fails, a .gitattributes file is pulled that enforces LF line endings. I'm not sure why it pulls this file flakily, though.

poosomooso avatar Sep 23 '21 05:09 poosomooso

I wasn't able to reproduce this.

@Greg4cr Have you been successful in reproducing this?

@poosomooso Do you have more information on this?

Thanks, René

rjust avatar Jan 01 '22 01:01 rjust

@rjust Unfortunately, I have not been able to reproduce this. Just tried again on both of my laptops (Ubuntu, Mac OS).

Haven't tried yet, but we could remove this .gitattributes file on checkout and see if that breaks anything.

Greg4cr avatar Jan 03 '22 08:01 Greg4cr

I have encountered the same problem on my server (ubuntu 16.04). I guess this is caused by unstaged changes in Jsoup git. My workaround is to revise the defects4j/framework/core/Vcs/Git.pm https://github.com/rjust/defects4j/blob/74b5b81ba6a3de794b16b8503b88b9f6788d93fb/framework/core/Vcs/Git.pm#L49

into:

# just to remove unstaged changed
return "git clone $self->{repo} ${work_dir} 2>&1 && cd $work_dir && git add -A && git commit -m \"workaround: enable d4j checkout by adding unstaged changes\"  && git checkout $revision_id 2>&1";

Hope it helps.

DehengYang avatar Mar 29 '22 11:03 DehengYang

I have encountered the same problem on my server (ubuntu 16.04). I guess this is caused by unstaged changes in Jsoup git. My workaround is to revise the defects4j/framework/core/Vcs/Git.pm

https://github.com/rjust/defects4j/blob/74b5b81ba6a3de794b16b8503b88b9f6788d93fb/framework/core/Vcs/Git.pm#L49

into:

# just to remove unstaged changed
return "git clone $self->{repo} ${work_dir} 2>&1 && cd $work_dir && git add -A && git commit -m \"workaround: enable d4j checkout by adding unstaged changes\"  && git checkout $revision_id 2>&1";

Hope it helps.

Thanks Deheng,it worked. You help me a lot! :)

ozzydong avatar Jan 06 '23 13:01 ozzydong

I've just ran into this issue on a quite old machine and I've managed to reproduce the exact same error reported by @neelofarhassan.

$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: Scientific
Description:    Scientific Linux release 7.9 (Nitrogen)
Release:        7.9
Codename:       Nitrogen

$ git --version
git version 1.8.3.1
$ git clone defects4j/project_repos/jsoup.git jsoup-issue-353
Cloning into 'jsoup-issue-353'...
done.
$ cd jsoup-issue-353/

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   src/test/java/org/jsoup/parser/TokeniserStateTest.java
#
no changes added to commit (use "git add" and/or "git commit -a")

$ cat .gitattributes
*   text=auto eol=lf

$ git diff
warning: CRLF will be replaced by LF in src/test/java/org/jsoup/parser/TokeniserStateTest.java.
The file will have its original line endings in your working directory.
diff --git a/src/test/java/org/jsoup/parser/TokeniserStateTest.java b/src/test/java/org/jsoup/parser/TokeniserStateTest.java
index b50965e..3314894 100644
--- a/src/test/java/org/jsoup/parser/TokeniserStateTest.java
+++ b/src/test/java/org/jsoup/parser/TokeniserStateTest.java
@@ -1,209 +1,209 @@
-package org.jsoup.parser;
-
-import org.jsoup.Jsoup;
...

The main important bits are: warning: CRLF will be replaced by LF in src/test/java/org/jsoup/parser/TokeniserStateTest.java. The file will have its original line endings in your working directory.

This seems to me a git related issue. Git versions 2.33 and 2.44 handle this CRLF vs LF issue.

jose avatar Mar 06 '24 01:03 jose