summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ea55960)
raw | patch | inline | side by side (parent: ea55960)
author | Steffen Prohaska <prohaska@zib.de> | |
Sun, 11 Nov 2007 14:35:07 +0000 (15:35 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 19 Nov 2007 02:39:00 +0000 (18:39 -0800) |
This teaches "push <remote> HEAD" to resolve HEAD on the local
side to its real branch name, e.g. master, and then act as if
the real branch name was specified. So we have a shorthand for
pushing the current branch. Besides HEAD, no other symbolic ref
is resolved.
Thanks to Daniel Barkalow <barkalow@iabervon.org> for suggesting
this implementation, which is much simpler than the
implementation proposed before.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
side to its real branch name, e.g. master, and then act as if
the real branch name was specified. So we have a shorthand for
pushing the current branch. Besides HEAD, no other symbolic ref
is resolved.
Thanks to Daniel Barkalow <barkalow@iabervon.org> for suggesting
this implementation, which is much simpler than the
implementation proposed before.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-push.c | patch | blob | history | |
t/t5516-fetch-push.sh | patch | blob | history |
diff --git a/builtin-push.c b/builtin-push.c
index 6d1da07c46704f3de837044652f0a1fd149327ad..54fba0e8326cb23508d68dadfe0d31bbff41833c 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
strcat(tag, refs[i]);
ref = tag;
}
+ if (!strcmp("HEAD", ref)) {
+ unsigned char sha1_dummy[20];
+ ref = resolve_ref(ref, sha1_dummy, 1, NULL);
+ if (!ref)
+ die("HEAD cannot be resolved.");
+ if (prefixcmp(ref, "refs/heads/"))
+ die("HEAD cannot be resolved to branch.");
+ ref = xstrdup(ref + 11);
+ }
add_refspec(ref);
}
}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 86f9b5346a0d7d8807d8c37c063690540873813a..b0ff48816e91991b26d0158fe65ebd2e70450171 100755 (executable)
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
'
+test_expect_success 'push with HEAD' '
+
+ mk_test heads/master &&
+ git checkout master &&
+ git push testrepo HEAD &&
+ check_push_result $the_commit heads/master
+
+'
+
+test_expect_success 'push with HEAD nonexisting at remote' '
+
+ mk_test heads/master &&
+ git checkout -b local master &&
+ git push testrepo HEAD &&
+ check_push_result $the_commit heads/local
+'
+
test_expect_success 'push with dry-run' '
mk_test heads/master &&