Re: [PATCH] git builtin "push"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds <torvalds@xxxxxxxx> writes:

>> True, as long as you don't have any Push: lines in your .git/remotes/repo
>> file.  Any such lines act just like you gave them on the command line
>> which afaik effectively removes the ability to say "update all branches
>> we have in common".
>
> Ok, so my built-in version "fixes" that "feature". 
>
> 		Linus

Alternatively/additionally you could do something like the
attached patch.  However,...

I suspect that destination repositories that you would want to
define Push: and the ones you do not want to have any Push: are
of different nature and you would not mix them.  When you do
want to have any Push: line for a repository, you would _never_
want to use the "matching refs" semantics for that repository.
So in that sense, the "fix" is not necessary, and fixing it
would probably lead to more confusion.

The Push: lines can do two related but independent things:

 - limit the set of refs that are published (hide the uncooked topics)
 - remap the source and destination refs (e.g. push master to origin)

The first can be done by not having Push: at all and by solely
relying on "matching refs" semantics.  Then usually you can just
keep doing "git push <destination>" until you have something new
to add, at that point you say "git push <destination>
<newbranch>" just once, and after that keep doing the "matching
refs" push.  You are having the remote repository remember what
the set of refs you would want there, instead of listing them on
the local "Push:" lines.  All should work well that way.

I use Push: lines to push into my private, non-bare, repository
at kernel.org machines for the second reason.  I have:

	Push: heads/master:heads/origin
        Push: heads/next:heads/next
        Push: +heads/pu:heads/pu
        Push: heads/maint:heads/maint

and leave the "master" branch checked out over there.  After
pushing, I log-in, and start my work by "git pull . origin".

The "matching refs" feature actively does a wrong thing to
remote repositories managed this way.

-- >8 --
[PATCH] git push --common <repo>

If you usually push only specific branches, it is handy to have
Push: lines only for those branches in your remotes/<repo> file.
But with that, you cannot access the underlying git-send-pack's
ability to push "only matching refs".  The flag --common can be
given to ignore Push: lines and push only matching refs.

---
diff --git a/git-push.sh b/git-push.sh
index f10cadb..381b76f 100755
--- a/git-push.sh
+++ b/git-push.sh
@@ -11,6 +11,7 @@ has_exec=
 has_thin=--thin
 remote=
 do_tags=
+do_common=
 
 while case "$#" in 0) break ;; esac
 do
@@ -19,6 +20,8 @@ do
 		has_all=--all ;;
 	--tags)
 		do_tags=yes ;;
+	--common)
+		do_common=yes ;;
 	--force)
 		has_force=--force ;;
 	--exec=*)
@@ -45,10 +48,21 @@ esac
 . git-parse-remote
 remote=$(get_remote_url "$@")
 
-case "$has_all" in
---all)
+case "$has_all,$do_common" in
+--all,yes)
+	die "Both --common and --all given." ;;
+--all,)
 	set x ;;
-'')
+,yes)
+	case "$do_tags,$#" in
+	,1)
+		set x ;;
+	yes,*)
+		die "Both --common and --tags given." ;;
+	*)
+		die "Both --common and an explicit refspec given." ;;
+	esac ;;
+,)
 	case "$do_tags,$#" in
 	yes,1)
 		set x $(cd "$GIT_DIR/refs" && find tags -type f -print) ;;

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]