different status between JGit and console command "git status" [message #1760805] |
Wed, 03 May 2017 07:58 |
Youfeng Chen Messages: 1 Registered: May 2017 |
Junior Member |
|
|
I'm trying to use JGit to add file, commit and then push to remore git repository by software. the JGit version is: org.eclipse.jgit-4.6.1.201703071140-r.jar.
I find getUntracked and getMissing are NOT empty for a clean working directory.
the step is:
here is a master, ecg_dev and ecg_qa branch on remote, and in local, there is only master branch.
before doing other operations, I check status, and find the difference:
[root@sl1d-ecgagui01a ucdp_core]# git status
# On branch master
nothing to commit (working directory clean)
new displayGitRepoStatus Just enter commitConfigFileToGit
getChanged: []
getConflicting: []
getModified: []
getUntracked: [ucdpconfig_data/resources]
getUntrackedFolders: []
getAdded: []
getRemoved: []
getMissing: [...a lot of files here ...]
my code:
public static void displayGitRepoStatus(String displayInfo) {
System.out.println("new displayGitRepoStatus "+displayInfo);
try {
if(!openLocalRepository()) {
return;
}
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
StatusCommand statusCmd = GIT.status();
Status status;
status = statusCmd.call();
System.out.println("getChanged: "+status.getChanged());
System.out.println("getConflicting: "+status.getConflicting());
System.out.println("getModified: "+status.getModified());
System.out.println("getUntracked: "+status.getUntracked());
System.out.println("getUntrackedFolders: "+status.getUntrackedFolders());
System.out.println("getAdded: "+status.getAdded());
System.out.println("getRemoved: "+status.getRemoved());
System.out.println("getMissing: "+status.getMissing());
System.out.println("hasUncommittedChanges: "+status.hasUncommittedChanges());
System.out.println("isClean: "+status.isClean());
} catch (NoWorkTreeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I really need help to find out why this happens, thanks very much.
|
|
|
Powered by
FUDForum. Page generated in 0.02931 seconds