@matheusbsbs / matheus-bagliano / commits / 55b7835e1b
Fork 0

Log ref changes made by git-fetch and git-pull.

When git-fetch updates a reference record in the associated reflog what type of update took place and who caused it (git-fetch or git-pull, by invoking git-fetch). Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Jul 10, 2006 at 23:38 UTC 55b7835e1b81a6debc7648149d2b8a4c5c64ddba
2 files changed +16 -6
git-fetch.sh
+15 -5
@@ -11,6 +11,7 @@ LF='
11 '
12 IFS="$LF"
13
14 +rloga=fetch
15 no_tags=
16 tags=
17 append=
@@ -51,6 +52,9 @@ do
52 -k|--k|--ke|--kee|--keep)
53 keep=--keep
54 ;;
55 + --reflog-action=*)
56 + rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
57 + ;;
58 -*)
59 usage
60 ;;
@@ -75,6 +79,9 @@ refs=
79 rref=
80 rsync_slurped_objects=
81
82 +rloga="$rloga $remote_nick"
83 +test "$remote_nick" == "$remote" || rloga="$rloga $remote"
84 +
85 if test "" = "$append"
86 then
87 : >"$GIT_DIR/FETCH_HEAD"
@@ -149,11 +156,12 @@ fast_forward_local () {
156 [ "$verbose" ] && echo >&2 "* $1: same as $3"
157 else
158 echo >&2 "* $1: updating with $3"
159 + git-update-ref -m "$rloga: updating tag" "$1" "$2"
160 fi
161 else
162 echo >&2 "* $1: storing $3"
163 + git-update-ref -m "$rloga: storing tag" "$1" "$2"
164 fi
156 - git-update-ref "$1" "$2"
165 ;;
166
167 refs/heads/* | refs/remotes/*)
@@ -174,7 +182,7 @@ fast_forward_local () {
182 *,$local)
183 echo >&2 "* $1: fast forward to $3"
184 echo >&2 " from $local to $2"
177 - git-update-ref "$1" "$2" "$local"
185 + git-update-ref -m "$rloga: fast-forward" "$1" "$2" "$local"
186 ;;
187 *)
188 false
@@ -184,7 +192,7 @@ fast_forward_local () {
192 case ",$force,$single_force," in
193 *,t,*)
194 echo >&2 " forcing update."
187 - git-update-ref "$1" "$2" "$local"
195 + git-update-ref -m "$rloga: forced-update" "$1" "$2" "$local"
196 ;;
197 *)
198 echo >&2 " not updating."
@@ -194,7 +202,7 @@ fast_forward_local () {
202 }
203 else
204 echo >&2 "* $1: storing $3"
197 - git-update-ref "$1" "$2"
205 + git-update-ref -m "$rloga: storing head" "$1" "$2"
206 fi
207 ;;
208 esac
@@ -422,7 +430,9 @@ case ",$update_head_ok,$orig_head," in
430 curr_head=$(git-rev-parse --verify HEAD 2>/dev/null)
431 if test "$curr_head" != "$orig_head"
432 then
425 - git-update-ref HEAD "$orig_head"
433 + git-update-ref \
434 + -m "$rloga: Undoing incorrectly fetched HEAD." \
435 + HEAD "$orig_head"
436 die "Cannot fetch into the current branch."
437 fi
438 ;;
git-pull.sh
+1 -1
@@ -45,7 +45,7 @@ do
45 done
46
47 orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
48 -git-fetch --update-head-ok "$@" || exit 1
48 +git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1
49
50 curr_head=$(git-rev-parse --verify HEAD)
51 if test "$curr_head" != "$orig_head"