162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
362306a36Sopenharmony_ci
462306a36Sopenharmony_cidiff_patch=$1
562306a36Sopenharmony_ci
662306a36Sopenharmony_cimkdir -p "$(dirname "${diff_patch}")"
762306a36Sopenharmony_ci
862306a36Sopenharmony_cigit -C "${srctree:-.}" diff HEAD > "${diff_patch}"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciif [ ! -s "${diff_patch}" ] ||
1162306a36Sopenharmony_ci   [ -z "$(git -C "${srctree:-.}" ls-files --other --exclude-standard | head -n1)" ]; then
1262306a36Sopenharmony_ci	exit
1362306a36Sopenharmony_cifi
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci# The source tarball, which is generated by 'git archive', contains everything
1662306a36Sopenharmony_ci# you committed in the repository. If you have local diff ('git diff HEAD'),
1762306a36Sopenharmony_ci# it will go into ${diff_patch}. If untracked files are remaining, the resulting
1862306a36Sopenharmony_ci# source package may not be correct.
1962306a36Sopenharmony_ci#
2062306a36Sopenharmony_ci# Examples:
2162306a36Sopenharmony_ci#  - You modified a source file to add #include "new-header.h"
2262306a36Sopenharmony_ci#    but forgot to add new-header.h
2362306a36Sopenharmony_ci#  - You modified a Makefile to add 'obj-$(CONFIG_FOO) += new-dirver.o'
2462306a36Sopenharmony_ci#    but you forgot to add new-driver.c
2562306a36Sopenharmony_ci#
2662306a36Sopenharmony_ci# You need to commit them, or at least stage them by 'git add'.
2762306a36Sopenharmony_ci#
2862306a36Sopenharmony_ci# This script does not take care of untracked files because doing so would
2962306a36Sopenharmony_ci# introduce additional complexity. Instead, print a warning message here if
3062306a36Sopenharmony_ci# untracked files are found.
3162306a36Sopenharmony_ci# If all untracked files are just garbage, you can ignore this warning.
3262306a36Sopenharmony_ciecho >&2 "============================ WARNING ============================"
3362306a36Sopenharmony_ciecho >&2 "Your working tree has diff from HEAD, and also untracked file(s)."
3462306a36Sopenharmony_ciecho >&2 "Please make sure you did 'git add' for all new files you need in"
3562306a36Sopenharmony_ciecho >&2 "the source package."
3662306a36Sopenharmony_ciecho >&2 "================================================================="
37