From: James Bottomley <James.Bottomley@SteelEye.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [RFC] updates for git-pull-script
Date: Sun, 24 Apr 2005 09:14:29 -0500 [thread overview]
Message-ID: <1114352069.4997.24.camel@mulgrave> (raw)
The current git-pull-script has several behaviours that always trip me
up
1) when pulling from a local tree, you have to remember to append
the .git/ directory to the base
2) It always tries to checkout the files ... this drives me nuts since I
don't have a lot of space on my laptop so I keep most trees empty.
3) It doesn't attempt a more sophisticated merge. The SCSI tree seems
to be the one that always has added or removed files. Since I think
git-merge-one-file-script is reasonably trustworthy, I made automatic
merges using it one of the pull features.
4) It doesn't remember the old head. This is useful for unpulling
(pruning back to if the merge misfires) or simply seeing the changes
between the old and new heads.
The attached addresses all these points. It's what I use, but since
others may prefer the original behaviour, I'm sending it as a straw
horse.
James
--- a/git-pull-script
+++ b/git-pull-script
@@ -3,9 +3,17 @@
# use "$1" or something in a real script, this
# just hard-codes it.
#
-merge_repo=$1
+merge_repo="$1"
+
+[ -d .git ] || die
+
+if [ -d "$merge_repo" -a -d "$merge_repo/.git" ]; then
+ merge_repo="$merge_repo/.git"
+fi
rm -f .git/MERGE_HEAD
+rm -f .git/OLD_HEAD
+cp .git/HEAD .git/OLD_HEAD
echo "Getting object database"
rsync -avz --ignore-existing $merge_repo/objects/. .git/objects/.
@@ -32,17 +40,22 @@ if [ "$common" == "$merge_head" ]; then
fi
if [ "$common" == "$head" ]; then
echo "Updating from $head to $merge_head."
- echo "Destroying all noncommitted data!"
- echo "Kill me within 3 seconds.."
- sleep 3
- read-tree -m $merge_tree && checkout-cache -f -a && update-cache --refresh
+ echo "Reading the current tree"
+ read-tree -m $merge_tree || exit 1
echo $merge_head > .git/HEAD
exit 0
fi
echo "Trying to merge $merge_head into $head"
read-tree -m $common_tree $head_tree $merge_tree
-result_tree=$(write-tree) || exit 1
-result_commit=$(echo "Merge $merge_repo" | commit-tree $result_tree -p $head -p $merge_head)
+merge_msg="Merge $merge_repo"
+result_tree=$(write-tree 2>/dev/null)
+if [ $? -ne 0 ]; then
+ echo "Simple merge failed, trying Automatic merge"
+ merge-cache git-merge-one-file-script -a
+ merge_msg="Automatic merge of $merge_repo"
+ result_tree=$(write-tree) || exit 1
+fi
+result_commit=$(echo $merge_msg | commit-tree $result_tree -p $head -p $merge_head)
echo "Committed merge $result_commit"
echo $result_commit > .git/HEAD
-checkout-cache -f -a && update-cache --refresh
+#checkout-cache -f -a && update-cache --refresh
next reply other threads:[~2005-04-24 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-24 14:14 James Bottomley [this message]
2005-04-24 17:49 ` [RFC] updates for git-pull-script Linus Torvalds
2005-04-24 19:55 ` James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1114352069.4997.24.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).