From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Matthieu Moy <matthieu.moy@imag.fr>,
Ramkumar Ramachandra <artagnon@gmail.com>,
Jeff King <peff@peff.net>,
John Szakmeister <john@szakmeister.net>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v4 0/8] Introduce publish tracking branch
Date: Sun, 20 Apr 2014 14:44:58 -0500 [thread overview]
Message-ID: <1398023106-25958-1-git-send-email-felipe.contreras@gmail.com> (raw)
As it has been discussed before, our support for triangular workflows is
lacking, and the following patch series aims to improve that situation.
We have the concept of upstream branch (e.g. 'origin/master') which is to where
our topic branches eventually should be merged to, so it makes sense that
'git rebase' uses that as the destination, but most people would not push to
such upstream branch, they would push to a publish branch
(e.g. 'github/feature-a'). We could set our upstream to the place we push, and
'git push' would be able to use that as default, and 'git branch --vv' would
show how ahead/behind we are in comparisson to that branch, but then
'git rebase' (or 'git merge') would be using the wrong branch.
So, let's introduce the concept of a publish branch (similar to upstream),
which is used by push to determine the branch to push to, if the user hasn't
specified any manually, and overrides other configurations, such as
(push.default, and remote.$name.push).
This patch series adds:
1) git push --set-publish
2) git branch --set-publish
3) git branch -vv # uses and shows the publish branch when configured
4) @{publish} and @{p} marks
5) branch.$name.{push,pushremote} configurations
After this, it becomes much easier to track branches in a triangular workflow.
The publish branch is used instead of the upstream branch for tracking
information in 'git branch --vv' and 'git status' if present, otherwise there
are no changes (upstream is used).
master e230c56 [origin/master, gh/master] Git 1.8.4
* fc/publish 0a105fd [master, gh/fc/publish: ahead 1] branch: display publish branch
fc/branch/fast 177dcad [master, gh/fc/branch/fast] branch: reorganize verbose options
fc/trivial f289b9a [master: ahead 7] branch: trivial style fix
fc/leaks d101af4 [master: ahead 2] read-cache: plug a possible leak
stable e230c56 Git 1.8.4
Changes since v3:
* Fix a possible crash
* Improve tests so they work with newer push.default
diff --git a/builtin/push.c b/builtin/push.c
index 172e843..1beed0c 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -443,8 +443,8 @@ static int do_push(const char *repo, int flags)
if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
struct branch *branch = branch_get(NULL);
/* Is there a publish branch */
- if (branch->pushremote_name && !strcmp(remote->name, branch->pushremote_name) &&
- branch && branch->push_name) {
+ if (branch && branch->pushremote_name && !strcmp(remote->name, branch->pushremote_name) &&
+ branch->push_name) {
struct strbuf refspec = STRBUF_INIT;
strbuf_addf(&refspec, "%s:%s", branch->name, branch->push_name);
add_refspec(refspec.buf);
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index f9c528d..80a00e3 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1279,63 +1279,49 @@ EOF
git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo
'
-test_expect_success 'push with publish branch' '
+mk_publish_test () {
mk_test up_repo heads/master &&
mk_test down_repo heads/master &&
test_config remote.up.url up_repo &&
test_config remote.down.url down_repo &&
test_config branch.master.pushremote down &&
test_config branch.master.push for-john &&
+ test_config branch.master.remote up &&
+ test_config branch.master.merge master
+}
+
+test_expect_success 'push with publish branch' '
+ mk_publish_test &&
git push &&
check_push_result up_repo $the_first_commit heads/master &&
check_push_result down_repo $the_commit heads/for-john
'
test_expect_success 'push with publish branch for different remote' '
- mk_test up_repo heads/master &&
- mk_test down_repo heads/master &&
- test_config remote.up.url up_repo &&
- test_config remote.down.url down_repo &&
- test_config branch.master.pushremote down &&
- test_config branch.master.push for-john &&
+ mk_publish_test &&
git push up &&
check_push_result up_repo $the_commit heads/master &&
check_push_result down_repo $the_first_commit heads/master
'
test_expect_success 'push with publish branch with pushdefault' '
- mk_test up_repo heads/master &&
- mk_test down_repo heads/master &&
- test_config remote.up.url up_repo &&
- test_config remote.down.url down_repo &&
+ mk_publish_test &&
test_config remote.pushdefault up &&
- test_config branch.master.pushremote down &&
- test_config branch.master.push for-john &&
git push &&
check_push_result up_repo $the_first_commit heads/master &&
check_push_result down_repo $the_commit heads/for-john
'
test_expect_success 'push with publish branch with remote refspec' '
- mk_test up_repo heads/master &&
- mk_test down_repo heads/master &&
- test_config remote.up.url up_repo &&
- test_config remote.down.url down_repo &&
+ mk_publish_test &&
test_config remote.down.push refs/heads/master:refs/heads/bad &&
- test_config branch.master.pushremote down &&
- test_config branch.master.push for-john &&
git push &&
check_push_result up_repo $the_first_commit heads/master &&
check_push_result down_repo $the_commit heads/for-john
'
test_expect_success 'push with publish branch with manual refspec' '
- mk_test up_repo heads/master &&
- mk_test down_repo heads/master &&
- test_config remote.up.url up_repo &&
- test_config remote.down.url down_repo &&
- test_config branch.master.pushremote down &&
- test_config branch.master.push for-john &&
+ mk_publish_test &&
git push down master:good &&
check_push_result up_repo $the_first_commit heads/master &&
check_push_result down_repo $the_commit heads/good
Felipe Contreras (8):
t5516 (fetch-push): fix test restoration
Add concept of 'publish' branch
branch: add --set-publish-to option
push: add --set-publish option
branch: display publish branch
sha1_name: cleanup interpret_branch_name()
sha1_name: simplify track finding
sha1_name: add support for @{publish} marks
Documentation/config.txt | 7 ++++
Documentation/git-branch.txt | 11 +++++++
Documentation/git-push.txt | 9 +++++-
Documentation/revisions.txt | 4 +++
branch.c | 44 +++++++++++++++++++++++++
branch.h | 2 ++
builtin/branch.c | 74 ++++++++++++++++++++++++++++++++++++++----
builtin/push.c | 11 ++++++-
remote.c | 34 ++++++++++++++++----
remote.h | 4 +++
sha1_name.c | 62 ++++++++++++++++++++++--------------
t/t1508-at-combinations.sh | 5 +++
t/t3200-branch.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++
t/t5516-fetch-push.sh | 50 +++++++++++++++++++++++++++++
t/t5534-push-publish.sh | 70 ++++++++++++++++++++++++++++++++++++++++
t/t6040-tracking-info.sh | 5 +--
transport.c | 28 ++++++++++------
transport.h | 1 +
18 files changed, 449 insertions(+), 48 deletions(-)
create mode 100755 t/t5534-push-publish.sh
--
1.9.1+fc3.9.gc73078e
next reply other threads:[~2014-04-20 19:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-20 19:44 Felipe Contreras [this message]
2014-04-20 19:44 ` [PATCH v4 1/8] t5516 (fetch-push): fix test restoration Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 2/8] Add concept of 'publish' branch Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 3/8] branch: add --set-publish-to option Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 4/8] push: add --set-publish option Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 5/8] branch: display publish branch Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 6/8] sha1_name: cleanup interpret_branch_name() Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 7/8] sha1_name: simplify track finding Felipe Contreras
2014-04-20 19:45 ` [PATCH v4 8/8] sha1_name: add support for @{publish} marks Felipe Contreras
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=1398023106-25958-1-git-send-email-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=john@szakmeister.net \
--cc=matthieu.moy@imag.fr \
--cc=peff@peff.net \
/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).