[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16481329#comment-16481329 ] ASF GitHub Bot commented on SCM-868: asfgit closed pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java index 21ad47607..00da32475 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/add/GitAddCommand.java @@ -69,31 +69,12 @@ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fi { return result; } - + // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with relativeRepositoryPath -Commandline clRevparse = GitStatusCommand.createRevparseShowToplevelCommand( fileSet ); - -CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); -CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); +URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD( this, fileSet ); -URI relativeRepositoryPath = null; - int exitCode; - -exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr, getLogger() ); -if ( exitCode != 0 ) -{ -// git-status returns non-zero if nothing to do -if ( getLogger().isInfoEnabled() ) -{ -getLogger().info( "Could not resolve toplevel" ); -} -} -else -{ -relativeRepositoryPath = -GitStatusConsumer.resolveURI( stdout.getOutput().trim(), fileSet.getBasedir().toURI() ); -} +CommandLineUtils.StringStreamConsumer stderr; // git-add doesn't show single files, but only summary :/ // so we must run git-status and consume the output diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java index 1766acabb..30d6c70ea 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java @@ -121,27 +121,7 @@ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, Sc // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with // relativeRepositoryPath -Commandline clRevparse = GitStatusCommand.createRevparseShowToplevelCommand( fileSet ); - -stdout = new CommandLineUtils.StringStreamConsumer(); -stderr = new CommandLineUtils.StringStreamConsumer(); - -URI relativeRepositoryPath = null; - -exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr, getLogger() ); -if ( exitCode != 0 ) -{ -// git-status returns non-zero if nothing to do -if ( getLogger().isInfoEnabled() ) -{ -getLogger().info( "Could not resolve toplevel" ); -} -} -else -{ -relativeRepositoryPath = -GitStatusConsumer.resolveURI( stdout.getOutput().trim(), fileSet.getBasedir().toURI() ); -} +URI relativeRepositoryPath = GitStatusCommand.getRelativeCWD( this, fileSet ); // git-commit doesn't show single files, but only summary :/ // so we must run git-status and consume the output diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478718#comment-16478718 ] ASF GitHub Bot commented on SCM-868: basinilya commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r188872607 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -187,23 +187,33 @@ public void testConsumerModifiedFile() assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); } +public void testURI() +throws Exception +{ +String path = "Not%Scheme:/sub dir"; +URI u = GitStatusConsumer.uriFromPath( path ); +assertEquals( path, u.getPath() ); +} + // SCM-740 public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/subDirectory/" ); +URI relativeCWD = URI.create( "" ); Review comment: checked. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478131#comment-16478131 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r188777653 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -187,23 +187,33 @@ public void testConsumerModifiedFile() assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); } +public void testURI() +throws Exception +{ +String path = "Not%Scheme:/sub dir"; +URI u = GitStatusConsumer.uriFromPath( path ); +assertEquals( path, u.getPath() ); +} + // SCM-740 public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/subDirectory/" ); +URI relativeCWD = URI.create( "" ); + File subdir = new File( dir, "subDirectory" ); subdir.mkdir(); FileUtils.write( new File( subdir, "project.xml" ), "data" ); - List changedFiles = getChangedFiles( "M subDirectory/project.xml", subdir, dir.toURI() ); +List changedFiles = getChangedFiles( "M subDirectory/project.xml", dir, relativeCWD ); Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478135#comment-16478135 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r18879 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -215,19 +225,23 @@ public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException public void testConsumerModifiedFileInComplexDirectoryWithSpaces() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/sub Directory déjà vu special/" ); +URI relativeCWD = URI.create( "" ); + File subdir = new File( dir, "sub Directory déjà vu special" ); subdir.mkdir(); FileUtils.write( new File( subdir, "project.xml" ), "data" ); - List changedFiles = getChangedFiles( "M \"sub Directory déjà vu special/project.xml\"", subdir, dir.toURI() ); +List changedFiles = +getChangedFiles( "M \"sub Directory déjà vu special/project.xml\"", dir, relativeCWD ); assertNotNull( changedFiles ); assertEquals( 1, changedFiles.size() ); assertEquals( "sub Directory déjà vu special/project.xml", changedFiles.get( 0 ).getPath() ); FileUtils.write( new File( subdir, "test file with spaces and a déjà vu character.xml" ), "data" ); - changedFiles = getChangedFiles( "M \"sub Directory déjà vu special/test file with spaces and a déjà vu character.xml\"", subdir, dir.toURI() ); +changedFiles = Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478133#comment-16478133 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r18827 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -215,19 +225,23 @@ public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException public void testConsumerModifiedFileInComplexDirectoryWithSpaces() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/sub Directory déjà vu special/" ); +URI relativeCWD = URI.create( "" ); Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478132#comment-16478132 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r18804 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -187,23 +187,33 @@ public void testConsumerModifiedFile() assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); } +public void testURI() +throws Exception +{ +String path = "Not%Scheme:/sub dir"; +URI u = GitStatusConsumer.uriFromPath( path ); +assertEquals( path, u.getPath() ); +} + // SCM-740 public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/subDirectory/" ); +URI relativeCWD = URI.create( "" ); + File subdir = new File( dir, "subDirectory" ); subdir.mkdir(); FileUtils.write( new File( subdir, "project.xml" ), "data" ); - List changedFiles = getChangedFiles( "M subDirectory/project.xml", subdir, dir.toURI() ); +List changedFiles = getChangedFiles( "M subDirectory/project.xml", dir, relativeCWD ); assertNotNull( changedFiles ); assertEquals( 1, changedFiles.size() ); assertEquals( "subDirectory/project.xml", changedFiles.get( 0 ).getPath() ); FileUtils.write( new File( subdir, "test file with spaces and a déjà vu character.xml" ), "data" ); - changedFiles = getChangedFiles( "M \"subDirectory/test file with spaces and a déjà vu character.xml\"", subdir, dir.toURI() ); +changedFiles = Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478134#comment-16478134 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r18845 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -215,19 +225,23 @@ public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException public void testConsumerModifiedFileInComplexDirectoryWithSpaces() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/sub Directory déjà vu special/" ); +URI relativeCWD = URI.create( "" ); + File subdir = new File( dir, "sub Directory déjà vu special" ); subdir.mkdir(); FileUtils.write( new File( subdir, "project.xml" ), "data" ); - List changedFiles = getChangedFiles( "M \"sub Directory déjà vu special/project.xml\"", subdir, dir.toURI() ); +List changedFiles = Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478129#comment-16478129 ] ASF GitHub Bot commented on SCM-868: michael-o commented on a change in pull request #66: [SCM-868] fix gitexe cannot deduce relative path URL: https://github.com/apache/maven-scm/pull/66#discussion_r188777542 ## File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumerTest.java ## @@ -187,23 +187,33 @@ public void testConsumerModifiedFile() assertEquals("test file with spaces and a special \u007f character.xml", changedFiles.get( 0 ).getPath() ); } +public void testURI() +throws Exception +{ +String path = "Not%Scheme:/sub dir"; +URI u = GitStatusConsumer.uriFromPath( path ); +assertEquals( path, u.getPath() ); +} + // SCM-740 public void testConsumerModifiedFileInComplexDirectorySetup() throws IOException { File dir = createTempDirectory(); - File subdir = new File( dir.getAbsolutePath() + "/subDirectory/" ); +URI relativeCWD = URI.create( "" ); Review comment: check indentation This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16474598#comment-16474598 ] Ilya Basin commented on SCM-868: [~michael-o] Done. I modified GitCheckInCommandNoBranchTest to demonstrate the problem. The system property "scm.test.tmpdir" now alters the test directory location. Default is "target/". Please checkout my branch and run: {code:java} mvn test -Dtest="GitCheckInCommandNoBranchTest#testCheckinNoBranch" -Dscm.test.tmpdir=D:\{code} It should succeed. Then revert the last commit (my fix) and repeat. It should fail with: {code:java} GitCheckInCommandNoBranchTest.testCheckinNoBranch:76 expected:<1> but was:<0>{code} > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16472681#comment-16472681 ] Michael Osipov commented on SCM-868: Can you please rebase your changes against master as well as provide a test project where I can see the faulty behavior? I am still having problem to understand the root cause, but am willing to merge your work. > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16471717#comment-16471717 ] Ilya Basin commented on SCM-868: If you run the "add" or "checkin" command on Windows with the current working directory and the env. var. "TMP" being on different drive letters, then the command result will be "zero files added" or "zero files checked in". Unfortunately, the unit tests of maven-scm don't check this. This issue, however, breaks WagonTestCase.testWagon() in maven-wagon when attempted to run for gitexe. > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16470774#comment-16470774 ] Michael Osipov commented on SCM-868: Its hard for me to understand the given issue and your proposed solution because I am completely unacquiant with the code. > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCM-868) gitexe add() does not return added files when invoked in subdir
[ https://issues.apache.org/jira/browse/SCM-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16371811#comment-16371811 ] ASF GitHub Bot commented on SCM-868: GitHub user basinilya opened a pull request: https://github.com/apache/maven-scm/pull/66 [SCM-868] fix gitexe cannot deduce relative path You can merge this pull request into a Git repository by running: $ git pull https://github.com/basinilya/maven-scm SCM-868 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-scm/pull/66.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #66 commit 23e7fd0722823693486410cf4f2c1ce05bc35fc0 Author: Ilya Basin Date: 2018-02-21T18:22:32Z [SCM-868] fix gitexe cannot deduce relative path > gitexe add() does not return added files when invoked in subdir > --- > > Key: SCM-868 > URL: https://issues.apache.org/jira/browse/SCM-868 > Project: Maven SCM > Issue Type: Bug > Components: maven-scm-provider-gitexe >Affects Versions: 1.9.5, 1.9.6 >Reporter: Ilya Basin >Priority: Major > > I'm going to add a wagon-scm test suite for git. One of the test cases is > calling the GitAddCommand command with: > {code:java} > repo: > file:///C:/progs/maven/maven-wagon/wagon-providers/wagon-scm/target/test-classes/test-repo-git-test/ > fileSet: basedir = > C:\Users\basin\AppData\Local\Temp\wagon-scm2020146470.checkout\file-list; > files = [test-resource.txt]{code} > After adding the files the command internally calls "git rev-parse > --show-toplevel" which prints: > {code:java} > C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout{code} > And on the next line it tries to do (pseudo code): > {code:java} > ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create( > "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout")){code} > This is so wrong! What were those people from SCM-709 trying to get? A double > dot ".."? The argument to the relativize() method MUST be a child, not a > parent, otherwise the argument is returned unchanged. > There are so many reasons why getting an absolute path from git is a bad > idea: Symlinks, Windows paths. > Nevertheless, there's a simple solution. The original problem was that "git > status --porcelain" printed paths relative to the top level instead of > relative to the base dir. > So we should just call > {code} > git rev-parse --show-prefix > {code} instead of "show-toplevel" and strip this prefix from the paths > printed by "git status" -- This message was sent by Atlassian JIRA (v7.6.3#76005)