login
Header Space

 
 

Re: Cleaning up git user-interface warts

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Han-Wen Nienhuys <hanwen@...>, <git@...>
Date: Thursday, November 16, 2006 - 3:47 pm

Linus Torvalds <torvalds@osdl.org> writes:


As you said, pull inherently involve a merge which implies the
existence of associated working tree, so I do not think there is
any room for --bare to get in the picture.  We already do the
checkout when we recover from a fetch that is used incorrectly
and updated the current branch head underneath us.

To give the list a summary of the discussion so far, here is a
consolidated patch.

-- >8 --
From: Linus Torvalds <torvalds@osdl.org>
Subject: git-pull: allow pulling into an empty repository

We used to complain that we cannot merge anything we fetched
with a local branch that does not exist yet.  Just treat the
case as a natural extension of fast forwarding and make the
local branch'es tip point at the same commit we just fetched.
After all an empty repository without an initial commit is an
ancestor of any commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---
diff --git a/git-pull.sh b/git-pull.sh
index ed04e7d..e23beb6 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -44,10 +44,10 @@ do
 	shift
 done
 
-orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?"
+orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
 git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1
 
-curr_head=$(git-rev-parse --verify HEAD)
+curr_head=$(git-rev-parse --verify HEAD 2>/dev/null)
 if test "$curr_head" != "$orig_head"
 then
 	# The fetch involved updating the current branch.
@@ -80,6 +80,11 @@ case "$merge_head" in
 	exit 0
 	;;
 ?*' '?*)
+	if test -z "$orig_head"
+	then
+		echo >&2 "Cannot merge multiple branches into empty head"
+		exit 1
+	fi
 	var=`git-repo-config --get pull.octopus`
 	if test -n "$var"
 	then
@@ -95,6 +100,13 @@ case "$merge_head" in
 	;;
 esac
 
+if test -z "$orig_head"
+then
+	git-update-ref -m "initial pull" HEAD $merge_head "" &&
+	git-read-tree --reset -u HEAD || exit 1
+	exit
+fi
+
 case "$strategy_args" in
 '')
 	strategy_args=$strategy_default_args

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Cleaning up git user-interface warts, Jakub Narebski, (Tue Nov 14, 5:30 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Tue Nov 14, 5:34 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Tue Nov 14, 6:56 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Tue Nov 14, 9:48 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Tue Nov 14, 10:10 pm)
Re: Cleaning up git user-interface warts, Petr Baudis, (Wed Nov 15, 4:12 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 4:26 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 4:50 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 5:18 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 12:20 am)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 2:03 pm)
Re: Cleaning up git user-interface warts, Petr Baudis, (Thu Nov 16, 12:30 am)
Re: Cleaning up git user-interface warts, Theodore Tso, (Wed Nov 15, 9:14 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 12:21 am)
Re: Cleaning up git user-interface warts, Theodore Tso, (Thu Nov 16, 12:07 pm)
Re: Cleaning up git user-interface warts , Sanjoy Mahajan, (Wed Nov 22, 7:21 pm)
Re: Cleaning up git user-interface warts, Theodore Tso, (Thu Nov 16, 12:49 pm)
Re: Cleaning up git user-interface warts, Alexandre Julliard, (Thu Nov 16, 7:34 am)
Re: Cleaning up git user-interface warts, Petr Baudis, (Thu Nov 16, 10:01 am)
Re: Cleaning up git user-interface warts, Alexandre Julliard, (Thu Nov 16, 11:48 am)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Wed Nov 15, 9:20 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 11:12 pm)
Re: Cleaning up git user-interface warts, Johannes Schindelin, (Thu Nov 16, 7:00 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 7:22 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 8:05 pm)
Re: Cleaning up git user-interface warts , Horst H. von Brand, (Wed Nov 22, 10:52 pm)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Thu Nov 16, 9:34 pm)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Fri Nov 17, 2:42 am)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Fri Nov 17, 3:32 am)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Fri Nov 17, 9:24 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 8:39 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 8:52 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 8:13 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 9:25 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 8:37 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 8:27 pm)
Re: Cleaning up git user-interface warts, Petr Baudis, (Thu Nov 16, 8:35 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 6:45 am)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 12:23 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 12:42 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 1:17 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 2:13 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 1:57 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 2:28 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 3:47 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 3:53 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 2:27 pm)
Re: multi-project repos (was Re: Cleaning up git user-interf..., Johannes Schindelin, (Thu Nov 16, 6:21 pm)
Re: multi-project repos (was Re: Cleaning up git user-interf..., Johannes Schindelin, (Thu Nov 16, 7:36 pm)
Re: multi-project repos (was Re: Cleaning up git user-interf..., Johannes Schindelin, (Thu Nov 16, 9:22 pm)
Re: multi-project repos (was Re: Cleaning up git user-interf..., Johannes Schindelin, (Thu Nov 16, 10:16 pm)
Re: multi-project repos, Junio C Hamano, (Thu Nov 16, 6:44 pm)
Re: multi-project repos, Johannes Schindelin, (Thu Nov 16, 8:29 pm)
Re: multi-project repos, Junio C Hamano, (Fri Nov 17, 1:39 pm)
Re: multi-project repos, Shawn Pearce, (Sat Nov 18, 2:02 am)
Re: multi-project repos, Junio C Hamano, (Sat Nov 18, 3:31 am)
Re: multi-project repos, Shawn Pearce, (Sat Nov 18, 3:45 am)
Re: multi-project repos, Junio C Hamano, (Fri Nov 17, 4:24 pm)
Re: multi-project repos, Junio C Hamano, (Thu Nov 16, 2:33 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 7:11 am)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 9:03 am)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Thu Nov 16, 9:11 am)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 7:47 am)
Re: Cleaning up git user-interface warts , Horst H. von Brand, (Mon Nov 20, 3:44 pm)
Re: Cleaning up git user-interface warts, Shawn Pearce, (Mon Nov 20, 3:46 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 10:03 pm)
Re: Cleaning up git user-interface warts, Han-Wen Nienhuys, (Wed Nov 15, 10:30 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 11:27 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Thu Nov 16, 12:07 am)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 11:35 pm)
Re: Cleaning up git user-interface warts, Andy Parkins, (Wed Nov 15, 2:58 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 3:32 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 3:18 pm)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Wed Nov 15, 3:39 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 4:09 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 4:21 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 4:40 pm)
Re: Cleaning up git user-interface warts, Theodore Tso, (Thu Nov 16, 12:26 am)
Re: Cleaning up git user-interface warts, Andreas Ericsson, (Thu Nov 16, 7:50 am)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 12:30 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 1:01 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Thu Nov 16, 1:30 pm)
Re: Cleaning up git user-interface warts, Sean, (Thu Nov 16, 1:44 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Wed Nov 15, 5:08 pm)
Re: Cleaning up git user-interface warts, Jerome Lovy, (Tue Nov 21, 9:25 am)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 5:45 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Wed Nov 15, 6:52 pm)
Re: Cleaning up git user-interface warts, Sean, (Wed Nov 15, 7:07 pm)
Re: Cleaning up git user-interface warts, Shawn Pearce, (Wed Nov 15, 7:02 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 7:33 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 12:37 pm)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Thu Nov 16, 1:57 pm)
Re: Cleaning up git user-interface warts, Carl Worth, (Thu Nov 16, 2:23 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Fri Nov 17, 4:41 am)
Re: Cleaning up git user-interface warts, Carl Worth, (Fri Nov 17, 5:18 am)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Fri Nov 17, 7:29 am)
Re: Cleaning up git user-interface warts, Johannes Schindelin, (Fri Nov 17, 6:11 am)
Re: Cleaning up git user-interface warts, Shawn Pearce, (Fri Nov 17, 12:58 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Fri Nov 17, 7:41 am)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Wed Nov 15, 11:02 pm)
Re: Cleaning up git user-interface warts, Andreas Ericsson, (Thu Nov 16, 7:35 am)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 8:08 pm)
Re: Cleaning up git user-interface warts, Linus Torvalds, (Wed Nov 15, 11:07 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 11:43 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 5:31 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 5:40 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 5:52 pm)
Re: Cleaning up git user-interface warts, Karl , (Fri Nov 17, 8:20 am)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 5:59 pm)
Re: Cleaning up git user-interface warts, Nicolas Pitre, (Wed Nov 15, 2:43 pm)
Re: Cleaning up git user-interface warts, Shawn Pearce, (Wed Nov 15, 2:49 pm)
Re: Cleaning up git user-interface warts, Marko Macek, (Wed Nov 15, 3:05 pm)
Re: Cleaning up git user-interface warts, Sean, (Wed Nov 15, 6:28 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 4:41 pm)
Re: Cleaning up git user-interface warts, Marko Macek, (Thu Nov 16, 2:07 am)
Re: Cleaning up git user-interface warts, Shawn Pearce, (Wed Nov 15, 6:07 pm)
Re: Cleaning up git user-interface warts, Junio C Hamano, (Wed Nov 15, 12:58 am)
Re: Cleaning up git user-interface warts, Michael K. Edwards, (Tue Nov 14, 10:27 pm)
speck-geostationary