Uploaded image for project: 'Maven SCM'
  1. Maven SCM
  2. SCM-868

gitexe add() does not return added files when invoked in subdir

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.9.5, 1.10.0
    • 1.10.0
    • None

    Description

      I'm going to add a wagon-scm test suite for git. One of the test cases is calling the GitAddCommand command with:

      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]

      After adding the files the command internally calls "git rev-parse --show-toplevel" which prints:

      C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout

      And on the next line it tries to do (pseudo code):

      ("file:/C:/Users/basin/AppData/Local/Temp/wagon-scm1144102340.checkout/file-list/").relativize(URI.create(
      "C:/Users/basin/AppData/Local/Temp/wagon-scm2020146470.checkout"))

      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

      git rev-parse --show-prefix
      

      instead of "show-toplevel" and strip this prefix from the paths printed by "git status"

      Attachments

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              basinilya Ilya Basin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: