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
This commit is contained in:
30
remote.c
30
remote.c
@ -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 *))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user