elucideye / drishti

Real time eye tracking for embedded and mobile devices.
BSD 3-Clause "New" or "Revised" License
391 stars 82 forks source link

FATAL ERROR w/ GIT_SELF and "dirty" directory #705

Closed headupinclouds closed 6 years ago

headupinclouds commented 6 years ago

Reported here: https://github.com/elucideye/drishti/issues/696#issuecomment-411934091

Just tried to build it. Drishti compiled from the source w/o a problem but building inside the Android Studio (AS) failed. The error:

Found Git: /usr/bin/git (found version "2.17.1") 
[hunter *** DEBUG *** 2018-08-10T01:39:15] Using git executable: /usr/bin/git
[hunter *** DEBUG *** 2018-08-10T01:39:15] Run command '/usr/bin/git;status;--porcelain' in '/home/matej/temp/t/drishti' directory
[hunter *** DEBUG *** 2018-08-10T01:39:15] All changes in '/home/matej/temp/t/drishti/src/examples' directory will be ignored
[hunter ** FATAL ERROR **] Git directory is dirty: '/home/matej/temp/t/drishti/master.zip'
[hunter ** FATAL ERROR **] Please commit or stash changes.
[hunter ** FATAL ERROR **] [Directory:/home/matej/temp/t/drishti/src/examples/drishti-upload]

Relevant code: https://github.com/ruslo/hunter/blob/master/cmake/modules/hunter_pack_git_submodule.cmake#L81-L103

  set(cmd "${git_executable}" status --porcelain)
  execute_process(
      COMMAND ${cmd}
      WORKING_DIRECTORY "${submodule_dir}"
      RESULT_VARIABLE result
      OUTPUT_VARIABLE output
      ERROR_VARIABLE error
      OUTPUT_STRIP_TRAILING_WHITESPACE
      ERROR_STRIP_TRAILING_WHITESPACE
  )

  if(NOT result EQUAL "0")
    hunter_internal_error(
        "Command failed: ${cmd} (${result}, ${output}, ${error})"
    )
  endif()

  if(NOT "${output}" STREQUAL "")
    hunter_user_error(
        "Git directory '${submodule_dir}' is dirty."
        "Please commit or stash changes."
    )
  endif()

The basic command is:

/usr/bin/git status --porcelain 

From the top drishti repository.

Current solution: remove the new/offending files.

Long term solution: If practical, it would be nice to allow GIT_SELF to work with some extra local files. It may be worth making a distinction between local changes to committed files and new files in the repository (i.e., my_notes.txt).

Notes: https://www.stefanjudis.com/today-i-learned/the-short-version-of-git-status-and-the-close-but-different-porcelain-mode/

When you execute git status with this flag the result looks as follows:

git status --porcelain
M nuxt.config.js
M package-lock.json
M package.json
?? untracked.file

I think a conservative changes is to allow ?? but bark about M changes.

ruslo commented 6 years ago

GIT_SELF should be used only when we are building from drishti/src/examples (which is useful for testing or as a template for new project). Usually drishti should be used as a starting directory and GIT_SELF will not be applied. I have checked Android Studio build and it seems to work with this fix from master.

ruslo commented 6 years ago

I think a conservative changes is to allow ??

Option HUNTER_GIT_SELF_IGNORE_UNTRACKED added to Hunter:

Set to ON by default in Drishti here: https://github.com/elucideye/drishti/pull/710

headupinclouds commented 6 years ago

Addressed in #710