@matheusbsbs / matheus-bagliano / commits / 4b441f47ce
Fork 0

git-fetch: allow updating the current branch in a bare repository.

Sometimes, people have only fetch access into a bare repository that is used as a back-up location (or a distribution point) but does not have a push access for networking reasons, e.g. one end being behind a firewall, and updating the "current branch" in such a case is perfectly fine. This allows such a fetch without --update-head-ok, which is a flag that should never be used by end users otherwise. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 7, 2007 at 02:17 UTC 4b441f47cefe7f4861167a151a395606e1a16745
2 files changed +13 -4
git-fetch.sh
+5 -4
@@ -231,11 +231,12 @@ update_local_ref () {
231 esac
232 }
233
234 -case "$update_head_ok" in
235 -'')
234 +# updating the current HEAD with git-fetch in a bare
235 +# repository is always fine.
236 +if test -z "$update_head_ok" && test $(is_bare_repository) = false
237 +then
238 orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
237 - ;;
238 -esac
239 +fi
240
241 # If --tags (and later --heads or --all) is specified, then we are
242 # not talking about defaults stored in Pull: line of remotes or
git-sh-setup.sh
+8
@@ -28,6 +28,14 @@ set_reflog_action() {
28 fi
29 }
30
31 +is_bare_repository () {
32 + git-repo-config --bool --get core.bare ||
33 + case "$GIT_DIR" in
34 + .git | */.git) echo false ;;
35 + *) echo true ;;
36 + esac
37 +}
38 +
39 if [ -z "$LONG_USAGE" ]
40 then
41 LONG_USAGE="Usage: $0 $USAGE"