@matheusbsbs / matheus-bagliano / commits / a74b1706c8
Fork 0

git-pull: disallow implicit merging to detached HEAD

Instead, we complain to the user and suggest that they explicitly specify the remote and branch. We depend on the exit status of git-symbolic-ref, so let's go ahead and document that. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jeff King committed Jan 15, 2007 at 17:25 UTC a74b1706c89c5e966c64316575e0b33dd21b8128
2 files changed +15 -2
Documentation/git-symbolic-ref.txt
+4
@@ -44,6 +44,10 @@ cumbersome. On some platforms, `ln -sf` does not even work as
44 advertised (horrors). Therefore symbolic links are now deprecated
45 and symbolic refs are used by default.
46
47 +git-symbolic-ref will exit with status 0 if the contents of the
48 +symbolic ref were printed correctly, with status 1 if the requested
49 +name is not a symbolic ref, or 128 if another error occurs.
50 +
51 Author
52 ------
53 Written by Junio C Hamano <junkio@cox.net>
git-pull.sh
+11 -2
@@ -83,8 +83,17 @@ merge_head=$(sed -e '/ not-for-merge /d' \
83
84 case "$merge_head" in
85 '')
86 - curr_branch=$(git-symbolic-ref HEAD | \
87 - sed -e 's|^refs/heads/||')
86 + curr_branch=$(git-symbolic-ref -q HEAD)
87 + case $? in
88 + 0) ;;
89 + 1) echo >&2 "You are not currently on a branch; you must explicitly"
90 + echo >&2 "specify which branch you wish to merge:"
91 + echo >&2 " git pull <remote> <branch>"
92 + exit 1;;
93 + *) exit $?;;
94 + esac
95 + curr_branch=${curr_branch#refs/heads/}
96 +
97 echo >&2 "Warning: No merge candidate found because value of config option
98 \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
99 echo >&2 "No changes."