[ 
https://issues.apache.org/jira/browse/SCM-1029?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Markus Hoffrogge updated SCM-1029:
----------------------------------
    Description: 
*Issue*

If includes and/or excludes config is defined, then JGit checkIn is performing 
empty commits if no changes are applied to the effective fileset content BUT 
other files are changed that are NOT within the effective scope of the includes 
or excludes related fileset.

 

*Root cause*

Method *JGitCheckInCommand.executeCheckInCommand* is using 
git.status().call().{*}hasUncommittedChanges(){*} if there is nothing to commit 
returned by *JGitUtils.addAllFiles(git, fileSet).*

Since git.status().call().{*}hasUncommittedChanges(){*} returns the state of 
any file within the working tree of the repo, this will set *doCommit* true 
even in case there is no file changed or added in scope of the includes / 
excludes effective fileset.

 

*Solution*

Use OR condition of:
  - status.getAdded().size() > 0
  - status.getChanged().size() > 0
  - status.getRemoved() > 0

instead of status.hasUncommittedChanges() if an includes / excludes FileSet is 
specified.

[PR #238|https://github.com/apache/maven-scm/pull/238]


  was:
*Issue*

If includes and/or excludes config is defined, then JGit checkIn is performing 
empty commits if no changes are applied to the effective fileset content BUT 
other files are changed that are NOT within the effective scope of the includes 
or excludes related fileset.

 

*Root cause*

Method *JGitCheckInCommand.executeCheckInCommand* is using 
git.status().call().{*}hasUncommittedChanges(){*} if there is nothing to commit 
returned by *JGitUtils.addAllFiles(git, fileSet).*

Since git.status().call().{*}hasUncommittedChanges(){*} returns the state of 
any file within the working tree of the repo, this will set *doCommit* true 
even in case there is no file changed or added in scope of the includes / 
excludes effective fileset.

 

*Solution*

Use OR condition of:
  - status.getAdded().size() > 0
  - status.getChanged().size() > 0
  - status.getRemoved() > 0

instead of status.hasUncommittedChanges() if an includes / excludes FileSet is 
specified.

[PR 
#238|https://github.com/apache/maven-scm/pull/238]|https://github.com/apache/maven-scm/pull/238]


> JGit performing empty commit on CheckIn command if includes or excludes 
> fileset is defined but no files changed in it
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: SCM-1029
>                 URL: https://issues.apache.org/jira/browse/SCM-1029
>             Project: Maven SCM
>          Issue Type: Bug
>          Components: maven-scm-provider-jgit
>    Affects Versions: 2.1.0
>            Reporter: Markus Hoffrogge
>            Priority: Major
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> *Issue*
> If includes and/or excludes config is defined, then JGit checkIn is 
> performing empty commits if no changes are applied to the effective fileset 
> content BUT other files are changed that are NOT within the effective scope 
> of the includes or excludes related fileset.
>  
> *Root cause*
> Method *JGitCheckInCommand.executeCheckInCommand* is using 
> git.status().call().{*}hasUncommittedChanges(){*} if there is nothing to 
> commit returned by *JGitUtils.addAllFiles(git, fileSet).*
> Since git.status().call().{*}hasUncommittedChanges(){*} returns the state of 
> any file within the working tree of the repo, this will set *doCommit* true 
> even in case there is no file changed or added in scope of the includes / 
> excludes effective fileset.
>  
> *Solution*
> Use OR condition of:
>   - status.getAdded().size() > 0
>   - status.getChanged().size() > 0
>   - status.getRemoved() > 0
> instead of status.hasUncommittedChanges() if an includes / excludes FileSet 
> is specified.
> [PR #238|https://github.com/apache/maven-scm/pull/238]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to