Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8365048

idea.sh script does not correctly detect/handle git worktrees

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • infrastructure

      When creating the vcs.xml file, the script attempts to determine if the directory is a "git repository" by doing:

      if [ -d "$TOPLEVEL_DIR/.git" ] ; then
          VCS_TYPE="Git"
      fi

      However, in a worktree, while a '.git' file exists, it's a normal file.

      The simplest (but heuristic) way to improve this would be to change this test to:

      if [ -f "$TOPLEVEL_DIR/.git" ] ; then ...

      Since that covers both files and directories, but a less heuristic approach (if amenable to this cross platform script) would be to test the directory using git itself (if installed).

      GITCMD="$(which git 2> /dev/null)"
      if [[ -n "$GITCMD" && -x "$GITCMD" ]] && "$GITCMD" 'rev-parse' '--git-dir' > /dev/null 2>&1 ; then
          VCS_TYPE="Git"
      fi

      This code does the "right thing" on Fedora Linux, but obviously Cygwin and MaxOS etc. need checking in order to be happy it.

            Unassigned Unassigned
            dabeaumo David Beaumont
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: