Browse files

git-archive-and-format-patch: Don't break when called from a non-topl…

…evel directory

Some of the commands called by git-archive-and-format-patch didn't work properly when called from a lower-level directory, so the script now cds to the top-level directory before doing anything.
  • Loading branch information...
1 parent c805d21 commit 8722d6d6d9649f685524c141f2b54367b9b0029b @MaxNanasy committed Feb 21, 2013
Showing with 14 additions and 10 deletions.
  1. +14 −10 git-archive-and-format-patch
24 git-archive-and-format-patch
@@ -7,25 +7,29 @@ else
+cd "$(git rev-parse --show-toplevel)"
merge_base="$(git merge-base "$start_commit" "$end_commit")"
-[ -d archive-and-format-patch ] && rm -r archive-and-format-patch
-mkdir archive-and-format-patch
+[ -d "$output_directory" ] && rm -r "$output_directory"
+mkdir "$output_directory"
# XXX git diff --diff-filter=D should only need to be called once
git diff --quiet --diff-filter=D "$merge_base" "$end_commit" ||
- git diff --diff-filter=D --name-only "$merge_base" "$end_commit" > archive-and-format-patch/deleted-files
+ git diff --diff-filter=D --name-only "$merge_base" "$end_commit" > "$output_directory/deleted-files"
# XXX git diff --diff-filter=AM should only need to be called once
git diff --quiet --diff-filter=AM "$merge_base" "$end_commit" ||
git diff -z --diff-filter=AM --name-only "$merge_base" "$end_commit" |
- xargs -0 git archive -o archive-and-format-patch/ "$end_commit" --
+ xargs -0 git archive -o "$output_directory/" "$end_commit" --
-git format-patch --quiet -o archive-and-format-patch/patches "$start_commit..$end_commit"
-if [ "$(ls archive-and-format-patch/patches | wc -l)" -gt 1 ]; then
- zip -qj archive-and-format-patch/patches{.zip,/*.patch}
- git diff --no-textconv "$merge_base" "$end_commit" > archive-and-format-patch/aggregate-patch.patch
+git format-patch --quiet -o "$output_directory/patches" "$start_commit..$end_commit"
+if [ "$(ls "$output_directory/patches" | wc -l)" -gt 1 ]; then
+ zip -qj "$output_directory/patches"{.zip,/*.patch}
+ git diff --no-textconv "$merge_base" "$end_commit" > "$output_directory/aggregate-patch.patch"
- cp archive-and-format-patch/{patches/*.patch,}
+ cp "$output_directory/"{patches/*.patch,}
-rm -r archive-and-format-patch/patches
+rm -r "$output_directory/patches"

0 comments on commit 8722d6d

Please sign in to comment.