diff options
| author | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:14:32 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:14:32 +0900 |
| commit | 093048b22913be23fe45635e8723d3aa3a185ff3 (patch) | |
| tree | 06a0911c433afb298a50329663c6c1a4fb3a8e8f /remote.c | |
| parent | Merge branch 'jt/submodule-tests-cleanup' (diff) | |
| parent | for-each-ref: test :remotename and :remoteref (diff) | |
| download | git-093048b22913be23fe45635e8723d3aa3a185ff3.tar.gz git-093048b22913be23fe45635e8723d3aa3a185ff3.zip | |
Merge branch 'js/for-each-ref-remote-name-and-ref'
The "--format=..." option "git for-each-ref" takes learned to show
the name of the 'remote' repository and the ref at the remote side
that is affected for 'upstream' and 'push' via "%(push:remotename)"
and friends.
* js/for-each-ref-remote-name-and-ref:
for-each-ref: test :remotename and :remoteref
for-each-ref: let upstream/push report the remote ref name
for-each-ref: let upstream/push optionally report the remote name
Diffstat (limited to 'remote.c')
| -rw-r--r-- | remote.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -675,6 +675,36 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit) return remote_for_branch(branch, explicit); } +const char *remote_ref_for_branch(struct branch *branch, int for_push, + int *explicit) +{ + if (branch) { + if (!for_push) { + if (branch->merge_nr) { + if (explicit) + *explicit = 1; + return branch->merge_name[0]; + } + } else { + const char *dst, *remote_name = + pushremote_for_branch(branch, NULL); + struct remote *remote = remote_get(remote_name); + + if (remote && remote->push_refspec_nr && + (dst = apply_refspecs(remote->push, + remote->push_refspec_nr, + branch->refname))) { + if (explicit) + *explicit = 1; + return dst; + } + } + } + if (explicit) + *explicit = 0; + return ""; +} + static struct remote *remote_get_1(const char *name, const char *(*get_default)(struct branch *, int *)) { |
