@matheusbsbs / matheus-bagliano / commits / 38762c47d6
Fork 0

scripts: do not get confused with HEAD in work tree

When you have a file called HEAD in your work tree, many commands that our scripts feed "HEAD" to would complain about the rev vs path ambiguity. A solution is to form command line more carefully by appending -- to them, which makes it clear that we mean HEAD rev not HEAD file. This patch would apply to maint. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 28, 2007 at 16:15 UTC 38762c47d6442dc0ce0f45533f9151877c485337
6 files changed +11 -11
git-am.sh
+4 -4
@@ -214,7 +214,7 @@ fi
214
215 case "$resolved" in
216 '')
217 - files=$(git diff-index --cached --name-only HEAD) || exit
217 + files=$(git diff-index --cached --name-only HEAD --) || exit
218 if [ "$files" ]; then
219 echo "Dirty index: cannot apply patches (dirty: $files)" >&2
220 exit 1
@@ -348,7 +348,7 @@ do
348 case "$resolved$interactive" in
349 tt)
350 # This is used only for interactive view option.
351 - git diff-index -p --cached HEAD >"$dotest/patch"
351 + git diff-index -p --cached HEAD -- >"$dotest/patch"
352 ;;
353 esac
354 esac
@@ -409,7 +409,7 @@ do
409 # trust what the user has in the index file and the
410 # working tree.
411 resolved=
412 - git diff-index --quiet --cached HEAD && {
412 + git diff-index --quiet --cached HEAD -- && {
413 echo "No changes - did you forget to use 'git add'?"
414 stop_here_user_resolve $this
415 }
@@ -431,7 +431,7 @@ do
431 then
432 # Applying the patch to an earlier tree and merging the
433 # result may have produced the same tree as ours.
434 - git diff-index --quiet --cached HEAD && {
434 + git diff-index --quiet --cached HEAD -- && {
435 echo No changes -- Patch already applied.
436 go_next
437 continue
git-filter-branch.sh
+1 -1
@@ -95,7 +95,7 @@ USAGE="[--env-filter <command>] [--tree-filter <command>] \
95 . git-sh-setup
96
97 git diff-files --quiet &&
98 - git diff-index --cached --quiet HEAD ||
98 + git diff-index --cached --quiet HEAD -- ||
99 die "Cannot rewrite branch(es) with a dirty working directory."
100
101 tempdir=.git-rewrite
git-merge-ours.sh
+1 -1
@@ -9,6 +9,6 @@
9 # because the current index is what we will be committing as the
10 # merge result.
11
12 -git diff-index --quiet --cached HEAD || exit 2
12 +git diff-index --quiet --cached HEAD -- || exit 2
13
14 exit 0
git-rebase--interactive.sh
+2 -2
@@ -52,7 +52,7 @@ require_clean_work_tree () {
52 git rev-parse --verify HEAD > /dev/null &&
53 git update-index --refresh &&
54 git diff-files --quiet &&
55 - git diff-index --cached --quiet HEAD ||
55 + git diff-index --cached --quiet HEAD -- ||
56 die "Working tree is dirty"
57 }
58
@@ -331,7 +331,7 @@ do
331 git rev-parse --verify HEAD > /dev/null &&
332 git update-index --refresh &&
333 git diff-files --quiet &&
334 - ! git diff-index --cached --quiet HEAD &&
334 + ! git diff-index --cached --quiet HEAD -- &&
335 . "$DOTEST"/author-script &&
336 export GIT_AUTHOR_NAME GIT_AUTHOR_NAME GIT_AUTHOR_DATE &&
337 git commit -F "$DOTEST"/message -e
git-rebase.sh
+2 -2
@@ -60,7 +60,7 @@ continue_merge () {
60 fi
61
62 cmt=`cat "$dotest/current"`
63 - if ! git diff-index --quiet HEAD
63 + if ! git diff-index --quiet HEAD --
64 then
65 if ! git-commit -C "$cmt"
66 then
@@ -253,7 +253,7 @@ fi
253
254 # The tree must be really really clean.
255 git update-index --refresh || exit
256 -diff=$(git diff-index --cached --name-status -r HEAD)
256 +diff=$(git diff-index --cached --name-status -r HEAD --)
257 case "$diff" in
258 ?*) echo "cannot rebase: your index is not up-to-date"
259 echo "$diff"
git-stash.sh
+1 -1
@@ -14,7 +14,7 @@ trap 'rm -f "$TMP-*"' 0
14 ref_stash=refs/stash
15
16 no_changes () {
17 - git diff-index --quiet --cached HEAD &&
17 + git diff-index --quiet --cached HEAD -- &&
18 git diff-files --quiet
19 }
20