gen-diff-patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. set -eu
  4. diff_patch=$1
  5. mkdir -p "$(dirname "${diff_patch}")"
  6. git -C "${srctree:-.}" diff HEAD > "${diff_patch}"
  7. if [ ! -s "${diff_patch}" ] ||
  8. [ -z "$(git -C "${srctree:-.}" ls-files --other --exclude-standard | head -n1)" ]; then
  9. exit
  10. fi
  11. # The source tarball, which is generated by 'git archive', contains everything
  12. # you committed in the repository. If you have local diff ('git diff HEAD'),
  13. # it will go into ${diff_patch}. If untracked files are remaining, the resulting
  14. # source package may not be correct.
  15. #
  16. # Examples:
  17. # - You modified a source file to add #include "new-header.h"
  18. # but forgot to add new-header.h
  19. # - You modified a Makefile to add 'obj-$(CONFIG_FOO) += new-dirver.o'
  20. # but you forgot to add new-driver.c
  21. #
  22. # You need to commit them, or at least stage them by 'git add'.
  23. #
  24. # This script does not take care of untracked files because doing so would
  25. # introduce additional complexity. Instead, print a warning message here if
  26. # untracked files are found.
  27. # If all untracked files are just garbage, you can ignore this warning.
  28. echo >&2 "============================ WARNING ============================"
  29. echo >&2 "Your working tree has diff from HEAD, and also untracked file(s)."
  30. echo >&2 "Please make sure you did 'git add' for all new files you need in"
  31. echo >&2 "the source package."
  32. echo >&2 "================================================================="