[PATCH] Fix git_version.sh if builddir subdir of srcdir
Only accept the found git repo iff it is in our top srcdir, as determined by comparing absolute pathnames creaged by running "pwd" in the respective dir. In srcdir!=builddir builds, and if builddir is a subdirectory of srcdir, this caused "make distcheck" to fail. --- git_version.sh | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/git_version.sh b/git_version.sh index cfc5a4a..6f70076 100644 --- a/git_version.sh +++ b/git_version.sh @@ -104,6 +104,7 @@ else fi # Done with creating output files, so we can change to source dir +abs_srcdir="$(cd "$srcdir" && pwd)" cd "$srcdir" # Write program header @@ -142,7 +143,11 @@ fi git_repo=no # "git-rev-parse --git-dir" since git-0.99.7 -if [ "x$(git-rev-parse --git-dir 2> /dev/null)" != "x" ]; then +git_repo_dir="$(git-rev-parse --git-dir 2> /dev/null)" +abs_repo_dir="$(cd "$git_repo_dir" && pwd)" +# Only accept the found git repo iff it is in our top srcdir, as determined +# by comparing absolute pathnames creaged by running pwd in the respective dir. +if [ "x$git_repo_dir" != "x" ] && [ "x${abs_repo_dir}" = "x${abs_srcdir}/.git" ]; then git_repo=yes if [ "x$git_found" = "xyes" ]; then # git-1.4 and probably earlier understand "git-rev-parse HEAD" -- 1.5.3.4 -- To unsubscribe, e-mail: radeonhd+unsubscribe@opensuse.org For additional commands, e-mail: radeonhd+help@opensuse.org
Only accept the found git repo iff it is in our top srcdir, as determined by comparing absolute pathnames created by running "pwd" in the respective dir. Fixes bug introduced in ff796eba: In srcdir!=builddir builds, if builddir is a subdirectory of srcdir, "make distcheck" exposes a conflict between the dist tarballs' git_version.h and the new git_version.h erroneously created while compiling the source tree from the dist tarball. --- git_version.sh | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/git_version.sh b/git_version.sh index cfc5a4a..6f70076 100644 --- a/git_version.sh +++ b/git_version.sh @@ -104,6 +104,7 @@ else fi # Done with creating output files, so we can change to source dir +abs_srcdir="$(cd "$srcdir" && pwd)" cd "$srcdir" # Write program header @@ -142,7 +143,11 @@ fi git_repo=no # "git-rev-parse --git-dir" since git-0.99.7 -if [ "x$(git-rev-parse --git-dir 2> /dev/null)" != "x" ]; then +git_repo_dir="$(git-rev-parse --git-dir 2> /dev/null)" +abs_repo_dir="$(cd "$git_repo_dir" && pwd)" +# Only accept the found git repo iff it is in our top srcdir, as determined +# by comparing absolute pathnames creaged by running pwd in the respective dir. +if [ "x$git_repo_dir" != "x" ] && [ "x${abs_repo_dir}" = "x${abs_srcdir}/.git" ]; then git_repo=yes if [ "x$git_found" = "xyes" ]; then # git-1.4 and probably earlier understand "git-rev-parse HEAD" -- 1.5.3.4 -- To unsubscribe, e-mail: radeonhd+unsubscribe@opensuse.org For additional commands, e-mail: radeonhd+help@opensuse.org
On Nov 30, 07 15:30:50 +0100, Hans Ulrich Niedermann wrote:
Only accept the found git repo iff it is in our top srcdir, as determined by comparing absolute pathnames created by running "pwd" in the respective dir.
Pushed.
Matthias
--
Matthias Hopf
participants (2)
-
Hans Ulrich Niedermann
-
Matthias Hopf