Browse Source

Clean up different special *HEAD handling

We codify the following different heads (in addition to the main "HEAD",
which points to the current branch, of course):

 - FETCH_HEAD

   Populated by "git fetch"

 - ORIG_HEAD

   The old HEAD before a "git pull/resolve" (successful or not)

 - LAST_MERGE

   The HEAD we're currently merging in "git pull/resolve"

 - MERGE_HEAD

   The previous head of a unresolved "git pull", which gets committed by
   a "git commit" after manually resolving the result

We used to have "MERGE_HEAD" be populated directly by the fetch, and we
removed ORIG_HEAD and LAST_MERGE too aggressively.
maint
Linus Torvalds 20 years ago
parent
commit
6b38a402e9
  1. 4
      git-fetch-script
  2. 2
      git-pull-script
  3. 4
      git-resolve-script

4
git-fetch-script

@ -35,7 +35,7 @@ download_objects () { @@ -35,7 +35,7 @@ download_objects () {
}

echo "Getting remote $merge_name"
download_one "$merge_repo/$merge_name" "$GIT_DIR"/MERGE_HEAD || exit 1
download_one "$merge_repo/$merge_name" "$GIT_DIR"/FETCH_HEAD || exit 1

echo "Getting object database"
download_objects "$merge_repo" "$(cat "$GIT_DIR"/MERGE_HEAD)" || exit 1
download_objects "$merge_repo" "$(cat "$GIT_DIR"/FETCH_HEAD)" || exit 1

2
git-pull-script

@ -17,5 +17,5 @@ git-fetch-script "$merge_repo" "$merge_head" || exit 1 @@ -17,5 +17,5 @@ git-fetch-script "$merge_repo" "$merge_head" || exit 1

git-resolve-script \
"$(cat "$GIT_DIR"/HEAD)" \
"$(cat "$GIT_DIR"/MERGE_HEAD)" \
"$(cat "$GIT_DIR"/FETCH_HEAD)" \
"$merge_name"

4
git-resolve-script

@ -12,7 +12,7 @@ merge_repo="$3" @@ -12,7 +12,7 @@ merge_repo="$3"
: ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}

dropheads() {
rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD" \
rm -f -- "$GIT_DIR/MERGE_HEAD" \
"$GIT_DIR/LAST_MERGE" || exit 1
}

@ -44,7 +44,7 @@ if [ "$common" == "$head" ]; then @@ -44,7 +44,7 @@ if [ "$common" == "$head" ]; then
echo "Updating from $head to $merge."
git-read-tree -u -m $head $merge || exit 1
echo $merge > "$GIT_DIR"/HEAD
git-diff-tree -p ORIG_HEAD HEAD | git-apply --stat
git-diff-tree -p $head $merge | git-apply --stat
dropheads
exit 0
fi

Loading…
Cancel
Save