Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 235882 | Differences between
and this patch

Collapse All | Expand All

(-)libs.git/apichanges.xml (+22 lines)
 Lines 111-116    Link Here 
111
        
111
        
112
        <change>
112
        <change>
113
            <api name="gitlibrary_api"/>
113
            <api name="gitlibrary_api"/>
114
            <summary>The log command returns also branches containing the commits from the result.</summary>
115
            <version major="1" minor="14"/>
116
            <date day="12" month="9" year="2013"/>
117
            <author login="ovrabec"/>
118
            <compatibility addition="yes"/>
119
            <description>
120
                <ul>
121
                <li>Adding a new method GitClient.log (SearchCriteria, boolean, ProgressMonitor)
122
                    allowing an API client to specify if he wants to know what branches contain
123
                    the returned commits applying the search criteria. Such information can
124
                    be used to filter the resulted commits by branches without a need to restart
125
                    the command again.</li>
126
                <li>Adding a method GitRevisionInfo.getBranches() returning all branches
127
                that are known to contain the commit.</li>
128
                </ul>
129
            </description>
130
            <class package="org.netbeans.libs.git" name="GitClient"/>
131
            <class package="org.netbeans.libs.git" name="GitRevisionInfo"/>
132
            <issue number="235882"/>
133
        </change>
134
        <change>
135
            <api name="gitlibrary_api"/>
114
            <summary>Adding a command setting the upstream branch/tracking of local branches</summary>
136
            <summary>Adding a command setting the upstream branch/tracking of local branches</summary>
115
            <version major="1" minor="12"/>
137
            <version major="1" minor="12"/>
116
            <date day="22" month="8" year="2013"/>
138
            <date day="22" month="8" year="2013"/>
(-)libs.git/manifest.mf (-1 / +1 lines)
 Lines 1-4    Link Here 
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.libs.git/1
2
OpenIDE-Module: org.netbeans.libs.git/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/git/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/git/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.13
4
OpenIDE-Module-Specification-Version: 1.14
(-)libs.git/src/org/netbeans/libs/git/GitClassFactoryImpl.java (-2 / +2 lines)
 Lines 129-136    Link Here 
129
    }
129
    }
130
130
131
    @Override
131
    @Override
132
    public GitRevisionInfo createRevisionInfo (RevCommit commit, Repository repository) {
132
    public GitRevisionInfo createRevisionInfo (RevCommit commit, Map<String, GitBranch> affectedBranches, Repository repository) {
133
        return new GitRevisionInfo(commit, repository);
133
        return new GitRevisionInfo(commit, affectedBranches, repository);
134
    }
134
    }
135
135
136
    @Override
136
    @Override
(-)libs.git/src/org/netbeans/libs/git/GitClient.java (-1 / +25 lines)
 Lines 792-797    Link Here 
792
792
793
    /**
793
    /**
794
     * Digs through the repository's history and returns revisions according to the given search criteria.
794
     * Digs through the repository's history and returns revisions according to the given search criteria.
795
     * No information about branches is returned, you
796
     * should call {@link #log(org.netbeans.libs.git.SearchCriteria, boolean, org.netbeans.libs.git.progress.ProgressMonitor)}
797
     * if you want to get such knowledge.
795
     * @param searchCriteria criteria filtering the returned revisions
798
     * @param searchCriteria criteria filtering the returned revisions
796
     * @param monitor progress monitor
799
     * @param monitor progress monitor
797
     * @return revisions that follow the given search criteria
800
     * @return revisions that follow the given search criteria
 Lines 799-806    Link Here 
799
     * @throws GitException an unexpected error occurs
802
     * @throws GitException an unexpected error occurs
800
     */
803
     */
801
    public GitRevisionInfo[] log (SearchCriteria searchCriteria, ProgressMonitor monitor) throws GitException.MissingObjectException, GitException {
804
    public GitRevisionInfo[] log (SearchCriteria searchCriteria, ProgressMonitor monitor) throws GitException.MissingObjectException, GitException {
805
        return log(searchCriteria, false, monitor);
806
    }
807
808
    /**
809
     * Digs through the repository's history and returns revisions according to
810
     * the given search criteria.
811
     *
812
     * @param searchCriteria criteria filtering the returned revisions
813
     * @param fetchBranchInfo if set to <code>true</code> then the command will
814
     * also fetch information ({@link GitRevisionInfo#getBranches()}) about what
815
     * branches contain the individual commits returned by the command. You can
816
     * use that information to filter returned commits by the branches they're
817
     * part of. Also note that the command will take more time to finish.
818
     * @param monitor progress monitor
819
     * @return revisions that follow the given search criteria
820
     * @throws GitException.MissingObjectException revision specified in search
821
     * criteria (or head if no such revision is specified) does not exist
822
     * @throws GitException an unexpected error occurs
823
     */
824
    public GitRevisionInfo[] log (SearchCriteria searchCriteria, boolean fetchBranchInfo, ProgressMonitor monitor) throws GitException.MissingObjectException, GitException {
802
        Repository repository = gitRepository.getRepository();
825
        Repository repository = gitRepository.getRepository();
803
        LogCommand cmd = new LogCommand(repository, getClassFactory(), searchCriteria, monitor, delegateListener);
826
        LogCommand cmd = new LogCommand(repository, getClassFactory(), searchCriteria,
827
                fetchBranchInfo, monitor, delegateListener);
804
        cmd.execute();
828
        cmd.execute();
805
        return cmd.getRevisions();
829
        return cmd.getRevisions();
806
    }
830
    }
(-)libs.git/src/org/netbeans/libs/git/GitRevisionInfo.java (-2 / +23 lines)
 Lines 45-52    Link Here 
45
import java.io.File;
45
import java.io.File;
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.Collections;
48
import java.util.HashMap;
49
import java.util.HashMap;
49
import java.util.Iterator;
50
import java.util.Iterator;
51
import java.util.LinkedHashMap;
50
import java.util.List;
52
import java.util.List;
51
import java.util.Map;
53
import java.util.Map;
52
import java.util.logging.Logger;
54
import java.util.logging.Logger;
 Lines 70-83    Link Here 
70
 */
72
 */
71
public final class GitRevisionInfo {
73
public final class GitRevisionInfo {
72
74
73
    private RevCommit revCommit;
75
    private final RevCommit revCommit;
74
    private Repository repository;
76
    private final Repository repository;
77
    private final Map<String, GitBranch> branches;
75
    private GitFileInfo[] modifiedFiles;
78
    private GitFileInfo[] modifiedFiles;
76
    private static final Logger LOG = Logger.getLogger(GitRevisionInfo.class.getName());
79
    private static final Logger LOG = Logger.getLogger(GitRevisionInfo.class.getName());
77
80
78
    GitRevisionInfo (RevCommit commit, Repository repository) {
81
    GitRevisionInfo (RevCommit commit, Repository repository) {
82
        this(commit, Collections.<String, GitBranch>emptyMap(), repository);
83
    }
84
85
    GitRevisionInfo (RevCommit commit, Map<String, GitBranch> affectedBranches, Repository repository) {
79
        this.revCommit = commit;
86
        this.revCommit = commit;
80
        this.repository = repository;
87
        this.repository = repository;
88
        this.branches = Collections.unmodifiableMap(affectedBranches);
81
    }
89
    }
82
90
83
    /**
91
    /**
 Lines 159-164    Link Here 
159
        return parents;
167
        return parents;
160
    }
168
    }
161
    
169
    
170
    /**
171
     * @return all branches known to contain this commit.
172
     */
173
    public Map<String, GitBranch> getBranches () {
174
        return branches;
175
    }
176
    
162
    private void listFiles() throws GitException {
177
    private void listFiles() throws GitException {
163
        RevWalk revWalk = new RevWalk(repository);
178
        RevWalk revWalk = new RevWalk(repository);
164
        TreeWalk walk = new TreeWalk(repository);
179
        TreeWalk walk = new TreeWalk(repository);
 Lines 198-203    Link Here 
198
            walk.release();
213
            walk.release();
199
        }
214
        }
200
    }
215
    }
216
217
    private static Map<String, GitBranch> buildBranches (RevCommit commit, Map<String, GitBranch> branches) {
218
        Map<String, GitBranch> retval = new LinkedHashMap<>(branches.size());
219
        
220
        return retval;
221
    }
201
    
222
    
202
    /**
223
    /**
203
     * Provides information about what happened to a file between two different commits.
224
     * Provides information about what happened to a file between two different commits.
(-)libs.git/src/org/netbeans/libs/git/jgit/GitClassFactory.java (-1 / +6 lines)
 Lines 42-47    Link Here 
42
package org.netbeans.libs.git.jgit;
42
package org.netbeans.libs.git.jgit;
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.util.Collections;
45
import java.util.List;
46
import java.util.List;
46
import java.util.Map;
47
import java.util.Map;
47
import org.eclipse.jgit.api.MergeResult;
48
import org.eclipse.jgit.api.MergeResult;
 Lines 103-109    Link Here 
103
104
104
    public abstract GitRevertResult createRevertResult (GitRevertResult.Status status, GitRevisionInfo createRevisionInfo, List<File> conflicts, List<File> failures);
105
    public abstract GitRevertResult createRevertResult (GitRevertResult.Status status, GitRevisionInfo createRevisionInfo, List<File> conflicts, List<File> failures);
105
    
106
    
106
    public abstract GitRevisionInfo createRevisionInfo (RevCommit commit, Repository repository);
107
    public final GitRevisionInfo createRevisionInfo (RevCommit commit, Repository repository) {
108
        return createRevisionInfo(commit, Collections.<String, GitBranch>emptyMap(), repository);
109
    }
110
    
111
    public abstract GitRevisionInfo createRevisionInfo (RevCommit commit, Map<String, GitBranch> affectedBranches, Repository repository);
107
112
108
    public abstract GitStatus createStatus (boolean tracked, String path, String workTreePath, File file, 
113
    public abstract GitStatus createStatus (boolean tracked, String path, String workTreePath, File file, 
109
                Status statusHeadIndex, Status statusIndexWC, Status statusHeadWC, 
114
                Status statusHeadIndex, Status statusIndexWC, Status statusHeadWC, 
(-)libs.git/src/org/netbeans/libs/git/jgit/Utils.java (+8 lines)
 Lines 83-88    Link Here 
83
import org.netbeans.libs.git.GitObjectType;
83
import org.netbeans.libs.git.GitObjectType;
84
import org.netbeans.libs.git.GitRevisionInfo;
84
import org.netbeans.libs.git.GitRevisionInfo;
85
import org.netbeans.libs.git.GitRevisionInfo.GitFileInfo;
85
import org.netbeans.libs.git.GitRevisionInfo.GitFileInfo;
86
import org.netbeans.libs.git.jgit.commands.ListBranchCommand;
87
import org.netbeans.libs.git.progress.ProgressMonitor;
86
88
87
/**
89
/**
88
 *
90
 *
 Lines 422-425    Link Here 
422
            return allBranches.get(remoteName + trackedBranchName);
424
            return allBranches.get(remoteName + trackedBranchName);
423
        }
425
        }
424
    }
426
    }
427
428
    public static Map getAllBranches (Repository repository, GitClassFactory fac, ProgressMonitor monitor) throws GitException {
429
        ListBranchCommand cmd = new ListBranchCommand(repository, fac, true, monitor);
430
        cmd.execute();
431
        return cmd.getBranches();
432
    }
425
}
433
}
(-)libs.git/src/org/netbeans/libs/git/jgit/commands/LogCommand.java (-10 / +86 lines)
 Lines 44-61    Link Here 
44
44
45
import java.io.File;
45
import java.io.File;
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.ArrayList;
47
import java.util.Collection;
48
import java.util.Collection;
49
import java.util.Collections;
48
import java.util.Date;
50
import java.util.Date;
49
import java.util.Iterator;
51
import java.util.Iterator;
52
import java.util.LinkedHashMap;
50
import java.util.LinkedList;
53
import java.util.LinkedList;
51
import java.util.List;
54
import java.util.List;
52
import java.util.Map;
55
import java.util.Map;
56
import java.util.logging.Level;
57
import java.util.logging.Logger;
53
import org.eclipse.jgit.errors.MissingObjectException;
58
import org.eclipse.jgit.errors.MissingObjectException;
54
import org.eclipse.jgit.lib.Constants;
59
import org.eclipse.jgit.lib.Constants;
55
import org.eclipse.jgit.lib.PersonIdent;
60
import org.eclipse.jgit.lib.PersonIdent;
56
import org.eclipse.jgit.lib.Repository;
61
import org.eclipse.jgit.lib.Repository;
57
import org.eclipse.jgit.revwalk.FollowFilter;
62
import org.eclipse.jgit.revwalk.FollowFilter;
58
import org.eclipse.jgit.revwalk.RevCommit;
63
import org.eclipse.jgit.revwalk.RevCommit;
64
import org.eclipse.jgit.revwalk.RevFlag;
59
import org.eclipse.jgit.revwalk.RevSort;
65
import org.eclipse.jgit.revwalk.RevSort;
60
import org.eclipse.jgit.revwalk.RevWalk;
66
import org.eclipse.jgit.revwalk.RevWalk;
61
import org.eclipse.jgit.revwalk.filter.AndRevFilter;
67
import org.eclipse.jgit.revwalk.filter.AndRevFilter;
 Lines 87-100    Link Here 
87
    private final List<GitRevisionInfo> revisions;
93
    private final List<GitRevisionInfo> revisions;
88
    private final String revision;
94
    private final String revision;
89
    private final SearchCriteria criteria;
95
    private final SearchCriteria criteria;
96
    private final boolean fetchBranchInfo;
97
    private static final Logger LOG = Logger.getLogger(LogCommand.class.getName());
90
98
91
    public LogCommand (Repository repository, GitClassFactory gitFactory, SearchCriteria criteria, ProgressMonitor monitor, RevisionInfoListener listener) {
99
    public LogCommand (Repository repository, GitClassFactory gitFactory, SearchCriteria criteria,
100
            boolean fetchBranchInfo, ProgressMonitor monitor, RevisionInfoListener listener) {
92
        super(repository, gitFactory, monitor);
101
        super(repository, gitFactory, monitor);
93
        this.monitor = monitor;
102
        this.monitor = monitor;
94
        this.listener = listener;
103
        this.listener = listener;
95
        this.criteria = criteria;
104
        this.criteria = criteria;
105
        this.fetchBranchInfo = fetchBranchInfo;
96
        this.revision = null;
106
        this.revision = null;
97
        this.revisions = new LinkedList<GitRevisionInfo>();
107
        this.revisions = new LinkedList<>();
98
    }
108
    }
99
    
109
    
100
    public LogCommand (Repository repository, GitClassFactory gitFactory, String revision, ProgressMonitor monitor, RevisionInfoListener listener) {
110
    public LogCommand (Repository repository, GitClassFactory gitFactory, String revision, ProgressMonitor monitor, RevisionInfoListener listener) {
 Lines 102-109    Link Here 
102
        this.monitor = monitor;
112
        this.monitor = monitor;
103
        this.listener = listener;
113
        this.listener = listener;
104
        this.criteria = null;
114
        this.criteria = null;
115
        this.fetchBranchInfo = false;
105
        this.revision = revision;
116
        this.revision = revision;
106
        this.revisions = new LinkedList<GitRevisionInfo>();
117
        this.revisions = new LinkedList<>();
107
    }
118
    }
108
119
109
    @Override
120
    @Override
 Lines 115-135    Link Here 
115
        } else {
126
        } else {
116
            RevWalk walk = new RevWalk(repository);
127
            RevWalk walk = new RevWalk(repository);
117
            RevWalk fullWalk = new RevWalk(repository);
128
            RevWalk fullWalk = new RevWalk(repository);
129
            Map<String, GitBranch> allBranches;
130
            Map<String, RevCommit> branchCommits;
131
            List<RevFlag> branchFlags;
132
            if (fetchBranchInfo) {
133
                allBranches = Utils.getAllBranches(repository, getClassFactory(), new DelegatingGitProgressMonitor(monitor));
134
                branchFlags = new ArrayList<>(allBranches.size());
135
                branchCommits = new LinkedHashMap<>(allBranches.size());
136
                for (Map.Entry<String, GitBranch> e : allBranches.entrySet()) {
137
                    if (e.getKey() != GitBranch.NO_BRANCH) {
138
                        RevFlag flag = walk.newFlag(e.getKey());
139
                        branchFlags.add(flag);
140
                        try {
141
                            RevCommit branchHeadCommit = walk.parseCommit(repository.resolve(e.getValue().getId()));
142
                            branchHeadCommit.add(flag);
143
                            branchHeadCommit.carry(flag);
144
                            walk.markStart(branchHeadCommit);
145
                        } catch (IOException ex) {
146
                            LOG.log(Level.INFO, null, ex);
147
                        }
148
                    }
149
                }
150
                walk.carry(branchFlags);
151
            } else {
152
                allBranches = Collections.<String, GitBranch>emptyMap();
153
                branchCommits = Collections.<String, RevCommit>emptyMap();
154
                branchFlags = Collections.<RevFlag>emptyList();
155
            }
118
            try {
156
            try {
157
                RevFlag interestingFlag = walk.newFlag("RESULT_FLAG"); //NOI18N
158
                walk.carry(interestingFlag);
119
                String revisionFrom = criteria.getRevisionFrom();
159
                String revisionFrom = criteria.getRevisionFrom();
120
                String revisionTo = criteria.getRevisionTo();
160
                String revisionTo = criteria.getRevisionTo();
121
                if (revisionTo != null && revisionFrom != null) {
161
                if (revisionTo != null && revisionFrom != null) {
122
                    for (RevCommit uninteresting : Utils.findCommit(repository, revisionFrom).getParents()) {
162
                    for (RevCommit uninteresting : Utils.findCommit(repository, revisionFrom).getParents()) {
123
                        walk.markUninteresting(walk.parseCommit(uninteresting));
163
                        walk.markUninteresting(walk.parseCommit(uninteresting));
124
                    }
164
                    }
125
                    walk.markStart(walk.lookupCommit(Utils.findCommit(repository, revisionTo)));
165
                    walk.markStart(markStartCommit(walk.lookupCommit(Utils.findCommit(repository, revisionTo)), interestingFlag));
126
                } else if (revisionTo != null) {
166
                } else if (revisionTo != null) {
127
                    walk.markStart(walk.lookupCommit(Utils.findCommit(repository, revisionTo)));
167
                    walk.markStart(markStartCommit(walk.lookupCommit(Utils.findCommit(repository, revisionTo)), interestingFlag));
128
                } else if (revisionFrom != null) {
168
                } else if (revisionFrom != null) {
129
                    for (RevCommit uninteresting : Utils.findCommit(repository, revisionFrom).getParents()) {
169
                    for (RevCommit uninteresting : Utils.findCommit(repository, revisionFrom).getParents()) {
130
                        walk.markUninteresting(walk.parseCommit(uninteresting));
170
                        walk.markUninteresting(walk.parseCommit(uninteresting));
131
                    }
171
                    }
132
                    walk.markStart(walk.lookupCommit(Utils.findCommit(repository, Constants.HEAD)));
172
                    walk.markStart(markStartCommit(walk.lookupCommit(Utils.findCommit(repository, Constants.HEAD)), interestingFlag));
133
                } else {
173
                } else {
134
                    ListBranchCommand branchCommand = new ListBranchCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
174
                    ListBranchCommand branchCommand = new ListBranchCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
135
                    branchCommand.execute();
175
                    branchCommand.execute();
 Lines 137-146    Link Here 
137
                        return;
177
                        return;
138
                    }
178
                    }
139
                    for (Map.Entry<String, GitBranch> e : branchCommand.getBranches().entrySet()) {
179
                    for (Map.Entry<String, GitBranch> e : branchCommand.getBranches().entrySet()) {
140
                        walk.markStart(walk.lookupCommit(Utils.findCommit(repository, e.getValue().getId())));
180
                        walk.markStart(markStartCommit(walk.lookupCommit(Utils.findCommit(repository, e.getValue().getId())), interestingFlag));
141
                    }
181
                    }
142
                }
182
                }
143
                applyCriteria(walk, criteria);
183
                applyCriteria(walk, criteria, interestingFlag);
144
                walk.sort(RevSort.TOPO);
184
                walk.sort(RevSort.TOPO);
145
                walk.sort(RevSort.COMMIT_TIME_DESC, true);
185
                walk.sort(RevSort.COMMIT_TIME_DESC, true);
146
                int remaining = criteria.getLimit();
186
                int remaining = criteria.getLimit();
 Lines 149-155    Link Here 
149
                    if (!applyCriteriaAfter(criteria, commit)) {
189
                    if (!applyCriteriaAfter(criteria, commit)) {
150
                        continue;
190
                        continue;
151
                    }
191
                    }
152
                    addRevision(getClassFactory().createRevisionInfo(fullWalk.parseCommit(commit), repository));
192
                    addRevision(getClassFactory().createRevisionInfo(fullWalk.parseCommit(commit),
193
                            getAffectedBranches(commit, allBranches, branchFlags), repository));
153
                    --remaining;
194
                    --remaining;
154
                }
195
                }
155
            } catch (MissingObjectException ex) {
196
            } catch (MissingObjectException ex) {
 Lines 190-196    Link Here 
190
        listener.notifyRevisionInfo(info);
231
        listener.notifyRevisionInfo(info);
191
    }
232
    }
192
233
193
    private void applyCriteria (RevWalk walk, SearchCriteria criteria) {
234
    private void applyCriteria (RevWalk walk, SearchCriteria criteria, final RevFlag partOfResultFlag) {
194
        File[] files = criteria.getFiles();
235
        File[] files = criteria.getFiles();
195
        if (files.length > 0) {
236
        if (files.length > 0) {
196
            Collection<PathFilter> pathFilters = Utils.getPathFilters(getRepository().getWorkTree(), files);
237
            Collection<PathFilter> pathFilters = Utils.getPathFilters(getRepository().getWorkTree(), files);
 Lines 208-213    Link Here 
208
        } else {
249
        } else {
209
            filter = RevFilter.NO_MERGES;
250
            filter = RevFilter.NO_MERGES;
210
        }
251
        }
252
        filter = AndRevFilter.create(filter, new RevFilter() {
253
254
            @Override
255
            public boolean include (RevWalk walker, RevCommit cmit) {
256
                return cmit.has(partOfResultFlag);
257
            }
258
259
            @Override
260
            public RevFilter clone () {
261
                return this;
262
            }
263
264
            @Override
265
            public boolean requiresCommitBody () {
266
                return false;
267
            }            
268
            
269
        });
211
        
270
        
212
//        String username = criteria.getUsername();
271
//        String username = criteria.getUsername();
213
//        if (username != null && !(username = username.trim()).isEmpty()) {
272
//        if (username != null && !(username = username.trim()).isEmpty()) {
 Lines 245-248    Link Here 
245
    private boolean applyTo (PersonIdent ident, String pattern) {
304
    private boolean applyTo (PersonIdent ident, String pattern) {
246
        return ident != null && new GitUser(ident.getName(), ident.getEmailAddress()).toString().contains(pattern);
305
        return ident != null && new GitUser(ident.getName(), ident.getEmailAddress()).toString().contains(pattern);
247
    }
306
    }
307
308
    private RevCommit markStartCommit (RevCommit commit, RevFlag interestingFlag) {
309
        commit.add(interestingFlag);
310
        return commit;
311
    }
312
313
    private Map<String, GitBranch> getAffectedBranches (RevCommit commit, Map<String, GitBranch> allBranches,
314
            List<RevFlag> branchFlags) {
315
        Map<String, GitBranch> affected = new LinkedHashMap<>(allBranches.size());
316
        for (RevFlag flag : branchFlags) {
317
            GitBranch b;
318
            if (commit.has(flag) && (b = allBranches.get(flag.toString())) != null) {
319
                affected.put(b.getName(), b);
320
            }
321
        }
322
        return affected;
323
    }
248
}
324
}
(-)libs.git/test/unit/src/org/netbeans/libs/git/jgit/commands/LogTest.java (-34 / +137 lines)
 Lines 47-53    Link Here 
47
import java.util.Date;
47
import java.util.Date;
48
import java.util.Map;
48
import java.util.Map;
49
import org.eclipse.jgit.api.Git;
49
import org.eclipse.jgit.api.Git;
50
import org.eclipse.jgit.lib.ObjectId;
51
import org.eclipse.jgit.lib.PersonIdent;
50
import org.eclipse.jgit.lib.PersonIdent;
52
import org.eclipse.jgit.lib.Repository;
51
import org.eclipse.jgit.lib.Repository;
53
import org.eclipse.jgit.revwalk.RevCommit;
52
import org.eclipse.jgit.revwalk.RevCommit;
 Lines 130-136    Link Here 
130
        GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
129
        GitRevisionInfo revision4 = client.commit(files, "modification4", null, null, NULL_PROGRESS_MONITOR);
131
        SearchCriteria crit = new SearchCriteria();
130
        SearchCriteria crit = new SearchCriteria();
132
        crit.setRevisionTo(revision4.getRevision());
131
        crit.setRevisionTo(revision4.getRevision());
133
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
132
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
134
        assertEquals(5, revisions.length);
133
        assertEquals(5, revisions.length);
135
        assertRevisions(revision4, revisions[0]);
134
        assertRevisions(revision4, revisions[0]);
136
        assertRevisions(revision3, revisions[1]);
135
        assertRevisions(revision3, revisions[1]);
 Lines 163-169    Link Here 
163
        SearchCriteria crit = new SearchCriteria();
162
        SearchCriteria crit = new SearchCriteria();
164
        crit.setRevisionFrom(revision2.getRevision());
163
        crit.setRevisionFrom(revision2.getRevision());
165
        crit.setRevisionTo(revision3.getRevision());
164
        crit.setRevisionTo(revision3.getRevision());
166
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
165
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
167
        assertEquals(2, revisions.length);
166
        assertEquals(2, revisions.length);
168
        assertRevisions(revision3, revisions[0]);
167
        assertRevisions(revision3, revisions[0]);
169
        assertRevisions(revision2, revisions[1]);
168
        assertRevisions(revision2, revisions[1]);
 Lines 174-180    Link Here 
174
        crit = new SearchCriteria();
173
        crit = new SearchCriteria();
175
        crit.setRevisionFrom(revision2.getRevision());
174
        crit.setRevisionFrom(revision2.getRevision());
176
        crit.setRevisionTo(revision4.getRevision());
175
        crit.setRevisionTo(revision4.getRevision());
177
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
176
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
178
        assertEquals(3, revisions.length);
177
        assertEquals(3, revisions.length);
179
        assertRevisions(revision4, revisions[0]);
178
        assertRevisions(revision4, revisions[0]);
180
        assertRevisions(revision3, revisions[1]);
179
        assertRevisions(revision3, revisions[1]);
 Lines 226-232    Link Here 
226
        GitRevisionInfo revisionB2 = client.commit(files, "modificationOnB-2", null, null, NULL_PROGRESS_MONITOR);
225
        GitRevisionInfo revisionB2 = client.commit(files, "modificationOnB-2", null, null, NULL_PROGRESS_MONITOR);
227
        SearchCriteria crit = new SearchCriteria();
226
        SearchCriteria crit = new SearchCriteria();
228
        crit.setRevisionTo("A");
227
        crit.setRevisionTo("A");
229
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
228
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
230
        assertEquals(4, revisions.length);
229
        assertEquals(4, revisions.length);
231
        assertRevisions(revisionA2, revisions[0]);
230
        assertRevisions(revisionA2, revisions[0]);
232
        assertRevisions(revisionA1, revisions[1]);
231
        assertRevisions(revisionA1, revisions[1]);
 Lines 235-241    Link Here 
235
        
234
        
236
        crit = new SearchCriteria();
235
        crit = new SearchCriteria();
237
        crit.setRevisionTo("B");
236
        crit.setRevisionTo("B");
238
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
237
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
239
        assertEquals(4, revisions.length);
238
        assertEquals(4, revisions.length);
240
        assertRevisions(revisionB2, revisions[0]);
239
        assertRevisions(revisionB2, revisions[0]);
241
        assertRevisions(revisionB1, revisions[1]);
240
        assertRevisions(revisionB1, revisions[1]);
 Lines 243-249    Link Here 
243
        assertRevisions(revision0, revisions[3]);
242
        assertRevisions(revision0, revisions[3]);
244
        
243
        
245
        // try both branches, how are the revisions sorted?
244
        // try both branches, how are the revisions sorted?
246
        revisions = client.log(new SearchCriteria(), NULL_PROGRESS_MONITOR);
245
        revisions = client.log(new SearchCriteria(), true, NULL_PROGRESS_MONITOR);
247
        assertEquals(6, revisions.length);
246
        assertEquals(6, revisions.length);
248
        assertRevisions(revisionB2, revisions[0]);
247
        assertRevisions(revisionB2, revisions[0]);
249
        assertRevisions(revisionA2, revisions[1]);
248
        assertRevisions(revisionA2, revisions[1]);
 Lines 280-286    Link Here 
280
        SearchCriteria crit = new SearchCriteria();
279
        SearchCriteria crit = new SearchCriteria();
281
        crit.setRevisionFrom(revision2.getRevision());
280
        crit.setRevisionFrom(revision2.getRevision());
282
        crit.setRevisionTo(revision4.getRevision());
281
        crit.setRevisionTo(revision4.getRevision());
283
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
282
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
284
        assertEquals(3, revisions.length);
283
        assertEquals(3, revisions.length);
285
        assertRevisions(revision4, revisions[0]);
284
        assertRevisions(revision4, revisions[0]);
286
        assertRevisions(revision3, revisions[1]);
285
        assertRevisions(revision3, revisions[1]);
 Lines 290-296    Link Here 
290
        crit.setRevisionFrom(revision2.getRevision());
289
        crit.setRevisionFrom(revision2.getRevision());
291
        crit.setRevisionTo(revision4.getRevision());
290
        crit.setRevisionTo(revision4.getRevision());
292
        crit.setLimit(2);
291
        crit.setLimit(2);
293
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
292
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
294
        assertEquals(2, revisions.length);
293
        assertEquals(2, revisions.length);
295
        assertRevisions(revision4, revisions[0]);
294
        assertRevisions(revision4, revisions[0]);
296
        assertRevisions(revision3, revisions[1]);
295
        assertRevisions(revision3, revisions[1]);
 Lines 328-334    Link Here 
328
        SearchCriteria crit = new SearchCriteria();
327
        SearchCriteria crit = new SearchCriteria();
329
        crit.setFiles(new File[] { f1 });
328
        crit.setFiles(new File[] { f1 });
330
        crit.setRevisionFrom(revision1.getRevision());
329
        crit.setRevisionFrom(revision1.getRevision());
331
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
330
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
332
        assertEquals(2, revisions.length);
331
        assertEquals(2, revisions.length);
333
        assertRevisions(revision3, revisions[0]);
332
        assertRevisions(revision3, revisions[0]);
334
        assertRevisions(revision1, revisions[1]);
333
        assertRevisions(revision1, revisions[1]);
 Lines 336-342    Link Here 
336
        crit = new SearchCriteria();
335
        crit = new SearchCriteria();
337
        crit.setFiles(new File[] { f2 });
336
        crit.setFiles(new File[] { f2 });
338
        crit.setRevisionFrom(revision1.getRevision());
337
        crit.setRevisionFrom(revision1.getRevision());
339
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
338
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
340
        assertEquals(2, revisions.length);
339
        assertEquals(2, revisions.length);
341
        assertRevisions(revision3, revisions[0]);
340
        assertRevisions(revision3, revisions[0]);
342
        assertRevisions(revision2, revisions[1]);
341
        assertRevisions(revision2, revisions[1]);
 Lines 344-350    Link Here 
344
        crit = new SearchCriteria();
343
        crit = new SearchCriteria();
345
        crit.setFiles(files);
344
        crit.setFiles(files);
346
        crit.setRevisionFrom(revision1.getRevision());
345
        crit.setRevisionFrom(revision1.getRevision());
347
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
346
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
348
        assertEquals(3, revisions.length);
347
        assertEquals(3, revisions.length);
349
        assertRevisions(revision3, revisions[0]);
348
        assertRevisions(revision3, revisions[0]);
350
        assertRevisions(revision2, revisions[1]);
349
        assertRevisions(revision2, revisions[1]);
 Lines 353-359    Link Here 
353
        crit = new SearchCriteria();
352
        crit = new SearchCriteria();
354
        crit.setFiles(new File[] { f1, f2, f3 });
353
        crit.setFiles(new File[] { f1, f2, f3 });
355
        crit.setRevisionFrom(revision1.getRevision());
354
        crit.setRevisionFrom(revision1.getRevision());
356
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
355
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
357
        assertEquals(4, revisions.length);
356
        assertEquals(4, revisions.length);
358
        assertRevisions(revision4, revisions[0]);
357
        assertRevisions(revision4, revisions[0]);
359
        assertRevisions(revision3, revisions[1]);
358
        assertRevisions(revision3, revisions[1]);
 Lines 363-369    Link Here 
363
        crit = new SearchCriteria();
362
        crit = new SearchCriteria();
364
        crit.setFiles(new File[] { workDir });
363
        crit.setFiles(new File[] { workDir });
365
        crit.setRevisionFrom(revision1.getRevision());
364
        crit.setRevisionFrom(revision1.getRevision());
366
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
365
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
367
        assertEquals(4, revisions.length);
366
        assertEquals(4, revisions.length);
368
        assertRevisions(revision4, revisions[0]);
367
        assertRevisions(revision4, revisions[0]);
369
        assertRevisions(revision3, revisions[1]);
368
        assertRevisions(revision3, revisions[1]);
 Lines 390-427    Link Here 
390
        GitRevisionInfo revision2 = client.commit(files, "modification2", null, user1, NULL_PROGRESS_MONITOR);
389
        GitRevisionInfo revision2 = client.commit(files, "modification2", null, user1, NULL_PROGRESS_MONITOR);
391
        
390
        
392
        SearchCriteria crit = new SearchCriteria();
391
        SearchCriteria crit = new SearchCriteria();
393
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
392
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
394
        assertEquals(3, revisions.length);
393
        assertEquals(3, revisions.length);
395
        
394
        
396
        crit = new SearchCriteria();
395
        crit = new SearchCriteria();
397
        crit.setUsername("git-test-user");
396
        crit.setUsername("git-test-user");
398
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
397
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
399
        assertEquals(2, revisions.length);
398
        assertEquals(2, revisions.length);
400
        assertRevisions(revision2, revisions[0]);
399
        assertRevisions(revision2, revisions[0]);
401
        assertRevisions(revision1, revisions[1]);
400
        assertRevisions(revision1, revisions[1]);
402
        
401
        
403
        crit = new SearchCriteria();
402
        crit = new SearchCriteria();
404
        crit.setUsername("git-test-user@domain.com");
403
        crit.setUsername("git-test-user@domain.com");
405
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
404
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
406
        assertEquals(2, revisions.length);
405
        assertEquals(2, revisions.length);
407
        assertRevisions(revision2, revisions[0]);
406
        assertRevisions(revision2, revisions[0]);
408
        assertRevisions(revision1, revisions[1]);
407
        assertRevisions(revision1, revisions[1]);
409
        
408
        
410
        crit = new SearchCriteria();
409
        crit = new SearchCriteria();
411
        crit.setUsername("test-user");
410
        crit.setUsername("test-user");
412
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
411
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
413
        assertEquals(2, revisions.length);
412
        assertEquals(2, revisions.length);
414
        assertRevisions(revision2, revisions[0]);
413
        assertRevisions(revision2, revisions[0]);
415
        assertRevisions(revision1, revisions[1]);
414
        assertRevisions(revision1, revisions[1]);
416
        
415
        
417
        crit = new SearchCriteria();
416
        crit = new SearchCriteria();
418
        crit.setUsername("git-test-user222@domain.com");
417
        crit.setUsername("git-test-user222@domain.com");
419
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
418
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
420
        assertEquals(0, revisions.length);
419
        assertEquals(0, revisions.length);
421
        
420
        
422
        crit = new SearchCriteria();
421
        crit = new SearchCriteria();
423
        crit.setUsername("git-test-user <git-test-user@domain.com>");
422
        crit.setUsername("git-test-user <git-test-user@domain.com>");
424
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
423
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
425
        assertEquals(2, revisions.length);
424
        assertEquals(2, revisions.length);
426
        assertRevisions(revision2, revisions[0]);
425
        assertRevisions(revision2, revisions[0]);
427
        assertRevisions(revision1, revisions[1]);
426
        assertRevisions(revision1, revisions[1]);
 Lines 441-470    Link Here 
441
        GitRevisionInfo revision1 = client.commit(files, "modification1\non master", null, null, NULL_PROGRESS_MONITOR);
440
        GitRevisionInfo revision1 = client.commit(files, "modification1\non master", null, null, NULL_PROGRESS_MONITOR);
442
        
441
        
443
        SearchCriteria crit = new SearchCriteria();
442
        SearchCriteria crit = new SearchCriteria();
444
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
443
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
445
        assertEquals(2, revisions.length);
444
        assertEquals(2, revisions.length);
446
        
445
        
447
        crit = new SearchCriteria();
446
        crit = new SearchCriteria();
448
        crit.setMessage("blablabla");
447
        crit.setMessage("blablabla");
449
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
448
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
450
        assertEquals(0, revisions.length);
449
        assertEquals(0, revisions.length);
451
        
450
        
452
        crit = new SearchCriteria();
451
        crit = new SearchCriteria();
453
        crit.setMessage("modification");
452
        crit.setMessage("modification");
454
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
453
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
455
        assertEquals(1, revisions.length);
454
        assertEquals(1, revisions.length);
456
        assertRevisions(revision1, revisions[0]);
455
        assertRevisions(revision1, revisions[0]);
457
        
456
        
458
        crit = new SearchCriteria();
457
        crit = new SearchCriteria();
459
        crit.setMessage("modification1\non master");
458
        crit.setMessage("modification1\non master");
460
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
459
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
461
        assertEquals(1, revisions.length);
460
        assertEquals(1, revisions.length);
462
        assertRevisions(revision1, revisions[0]);
461
        assertRevisions(revision1, revisions[0]);
463
        
462
        
464
        // see bug #228905
463
        // see bug #228905
465
        crit = new SearchCriteria();
464
        crit = new SearchCriteria();
466
        crit.setMessage("on master");
465
        crit.setMessage("on master");
467
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
466
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
468
        assertEquals(1, revisions.length);
467
        assertEquals(1, revisions.length);
469
        assertRevisions(revision1, revisions[0]);
468
        assertRevisions(revision1, revisions[0]);
470
    }
469
    }
 Lines 537-555    Link Here 
537
        
536
        
538
        SearchCriteria crit = new SearchCriteria();
537
        SearchCriteria crit = new SearchCriteria();
539
        crit.setRevisionTo("master");
538
        crit.setRevisionTo("master");
540
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
539
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
541
        assertEquals(4, revisions.length);
540
        assertEquals(4, revisions.length);
542
        assertRevisions(revisionMerge, revisions[0]);
541
        assertRevisions(revisionMerge, revisions[0]);
543
        
542
        
544
        crit = new SearchCriteria();
543
        crit = new SearchCriteria();
545
        crit.setIncludeMerges(true);
544
        crit.setIncludeMerges(true);
546
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
545
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
547
        assertEquals(4, revisions.length);
546
        assertEquals(4, revisions.length);
548
        assertRevisions(revisionMerge, revisions[0]);
547
        assertRevisions(revisionMerge, revisions[0]);
549
        
548
        
550
        crit = new SearchCriteria();
549
        crit = new SearchCriteria();
551
        crit.setIncludeMerges(false);
550
        crit.setIncludeMerges(false);
552
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
551
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
553
        assertEquals(3, revisions.length);
552
        assertEquals(3, revisions.length);
554
        assertRevisions(revisionMaster, revisions[0]);
553
        assertRevisions(revisionMaster, revisions[0]);
555
        assertRevisions(revisionBranch, revisions[1]);
554
        assertRevisions(revisionBranch, revisions[1]);
 Lines 582-588    Link Here 
582
        SearchCriteria crit = new SearchCriteria();
581
        SearchCriteria crit = new SearchCriteria();
583
        crit.setFrom(new Date(revision2.getCommitTime()));
582
        crit.setFrom(new Date(revision2.getCommitTime()));
584
        crit.setTo(new Date(revision3.getCommitTime()));
583
        crit.setTo(new Date(revision3.getCommitTime()));
585
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
584
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
586
        assertEquals(2, revisions.length);
585
        assertEquals(2, revisions.length);
587
        assertRevisions(revision3, revisions[0]);
586
        assertRevisions(revision3, revisions[0]);
588
        assertRevisions(revision2, revisions[1]);
587
        assertRevisions(revision2, revisions[1]);
 Lines 595-601    Link Here 
595
        crit = new SearchCriteria();
594
        crit = new SearchCriteria();
596
        crit.setFrom(new Date(revision2.getCommitTime()));
595
        crit.setFrom(new Date(revision2.getCommitTime()));
597
        crit.setTo(new Date(revision3.getCommitTime()));
596
        crit.setTo(new Date(revision3.getCommitTime()));
598
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
597
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
599
        assertEquals(2, revisions.length);
598
        assertEquals(2, revisions.length);
600
        assertRevisions(revision3, revisions[0]);
599
        assertRevisions(revision3, revisions[0]);
601
        assertRevisions(revision2, revisions[1]);
600
        assertRevisions(revision2, revisions[1]);
 Lines 603-609    Link Here 
603
        crit = new SearchCriteria();
602
        crit = new SearchCriteria();
604
        crit.setFrom(new Date(revision2.getCommitTime()));
603
        crit.setFrom(new Date(revision2.getCommitTime()));
605
        crit.setTo(new Date(revision4.getCommitTime()));
604
        crit.setTo(new Date(revision4.getCommitTime()));
606
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
605
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
607
        assertEquals(3, revisions.length);
606
        assertEquals(3, revisions.length);
608
        assertRevisions(revision4, revisions[0]);
607
        assertRevisions(revision4, revisions[0]);
609
        assertRevisions(revision3, revisions[1]);
608
        assertRevisions(revision3, revisions[1]);
 Lines 611-617    Link Here 
611
        
610
        
612
        crit = new SearchCriteria();
611
        crit = new SearchCriteria();
613
        crit.setFrom(new Date(revision2.getCommitTime()));
612
        crit.setFrom(new Date(revision2.getCommitTime()));
614
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
613
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
615
        assertEquals(3, revisions.length);
614
        assertEquals(3, revisions.length);
616
        assertRevisions(revision4, revisions[0]);
615
        assertRevisions(revision4, revisions[0]);
617
        assertRevisions(revision3, revisions[1]);
616
        assertRevisions(revision3, revisions[1]);
 Lines 641-647    Link Here 
641
        
640
        
642
        SearchCriteria crit = new SearchCriteria();
641
        SearchCriteria crit = new SearchCriteria();
643
        crit.setFiles(new File[] { to });
642
        crit.setFiles(new File[] { to });
644
        GitRevisionInfo[] revisions = client.log(crit, NULL_PROGRESS_MONITOR);
643
        GitRevisionInfo[] revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
645
        assertEquals(2, revisions.length);
644
        assertEquals(2, revisions.length);
646
        assertRevisions(revision3, revisions[0]);
645
        assertRevisions(revision3, revisions[0]);
647
        assertRevisions(revision2, revisions[1]);
646
        assertRevisions(revision2, revisions[1]);
 Lines 653-659    Link Here 
653
        crit = new SearchCriteria();
652
        crit = new SearchCriteria();
654
        crit.setFiles(new File[] { to });
653
        crit.setFiles(new File[] { to });
655
        crit.setFollowRenames(true);
654
        crit.setFollowRenames(true);
656
        revisions = client.log(crit, NULL_PROGRESS_MONITOR);
655
        revisions = client.log(crit, true, NULL_PROGRESS_MONITOR);
657
        assertEquals(4, revisions.length);
656
        assertEquals(4, revisions.length);
658
        assertRevisions(revision3, revisions[0]);
657
        assertRevisions(revision3, revisions[0]);
659
        assertRevisions(revision2, revisions[1]);
658
        assertRevisions(revision2, revisions[1]);
 Lines 688-693    Link Here 
688
        assertEquals(GitFileInfo.Status.MODIFIED, modifiedFiles.get(f).getStatus());
687
        assertEquals(GitFileInfo.Status.MODIFIED, modifiedFiles.get(f).getStatus());
689
        assertEquals(GitFileInfo.Status.MODIFIED, modifiedFiles.get(f2).getStatus());
688
        assertEquals(GitFileInfo.Status.MODIFIED, modifiedFiles.get(f2).getStatus());
690
    }
689
    }
690
    
691
    public void testLogWithBranchInfo () throws Exception {
692
        File f = new File(workDir, "f");
693
        File f2 = new File(workDir, "f2");
694
        write(f, "init");
695
        write(f2, "init");
696
        File[] files = new File[] { f, f2 };
697
        add(files);
698
        commit(files);
699
        
700
        write(f, "modification");
701
        add(files);
702
        commit(files);
703
        
704
        GitClient client = getClient(workDir);
705
        SearchCriteria crit = new SearchCriteria();
706
        crit.setRevisionTo("master");
707
        GitRevisionInfo[] log = client.log(crit, NULL_PROGRESS_MONITOR);
708
        for (GitRevisionInfo info : log) {
709
            // no branch info fetched by this version of the command
710
            assertEquals(0, info.getBranches().size());
711
        }
712
        
713
        log = client.log(crit, true, NULL_PROGRESS_MONITOR);
714
        for (GitRevisionInfo info : log) {
715
            // all commits are from master
716
            assertEquals(1, info.getBranches().size());
717
            assertNotNull(info.getBranches().get("master"));
718
        }
719
    }
720
    
721
    // commit in the middle of a named branch
722
    public void testLogWithBranchInfoMiddleCommit () throws Exception {
723
        File f = new File(workDir, "f");
724
        File f2 = new File(workDir, "f2");
725
        write(f, "init");
726
        write(f2, "init");
727
        File[] files = new File[] { f, f2 };
728
        add(files);
729
        GitClient client = getClient(workDir);
730
        GitRevisionInfo firstCommit = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
731
        
732
        client.createBranch("newbranch", "master", NULL_PROGRESS_MONITOR);
733
        
734
        write(f, "modification");
735
        add(files);
736
        commit(files);
737
        
738
        write(f2, "modification");
739
        add(files);
740
        commit(files);
741
        
742
        SearchCriteria crit = new SearchCriteria();
743
        crit.setRevisionFrom(firstCommit.getRevision());
744
        crit.setRevisionTo(firstCommit.getRevision());
745
        crit.setFiles(new File[] { f });
746
        GitRevisionInfo info = client.log(crit, true, NULL_PROGRESS_MONITOR)[0];
747
        // the initial commit is from master and head of newbranch
748
        assertNotNull(info.getBranches().get("newbranch"));
749
        assertEquals(2, info.getBranches().size());
750
    }
751
    
752
    public void testLogWithBranchInfoMoreBranches () throws Exception {
753
        File f = new File(workDir, "f");
754
        File f2 = new File(workDir, "f2");
755
        write(f, "init");
756
        write(f2, "init");
757
        File[] files = new File[] { f, f2 };
758
        add(files);
759
        commit(files);
760
        
761
        write(f, "modification");
762
        add(files);
763
        commit(files);
764
                
765
        GitClient client = getClient(workDir);
766
        client.createBranch("newbranch", "master", NULL_PROGRESS_MONITOR);
767
        write(f, "modification on trunk");
768
        add(files);
769
        commit(files);
770
        
771
        client.checkoutRevision("newbranch", true, NULL_PROGRESS_MONITOR);
772
        write(f, "modification on branch");
773
        add(files);
774
        commit(files);
775
        
776
        SearchCriteria crit = new SearchCriteria();
777
        // log across all branches
778
        GitRevisionInfo[] log = client.log(crit, true, NULL_PROGRESS_MONITOR);
779
        // branch commit
780
        assertEquals(1, log[0].getBranches().size());
781
        assertNotNull(log[0].getBranches().get("newbranch"));
782
        // master commit
783
        assertEquals(1, log[1].getBranches().size());
784
        assertNotNull(log[1].getBranches().get("master"));
785
        // common commit
786
        assertEquals(2, log[2].getBranches().size());
787
        assertNotNull(log[2].getBranches().get("master"));
788
        assertNotNull(log[2].getBranches().get("newbranch"));
789
        // initial commit
790
        assertEquals(2, log[3].getBranches().size());
791
        assertNotNull(log[3].getBranches().get("master"));
792
        assertNotNull(log[3].getBranches().get("newbranch"));
793
    }
691
794
692
    private void assertRevisions (GitRevisionInfo expected, GitRevisionInfo info) throws GitException {
795
    private void assertRevisions (GitRevisionInfo expected, GitRevisionInfo info) throws GitException {
693
        assertEquals(expected.getRevision(), info.getRevision());
796
        assertEquals(expected.getRevision(), info.getRevision());

Return to bug 235882
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo