git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Testing for existence of a remote branch from a script
@ 2025-01-06  4:40 Chris Packham
  2025-01-06  6:51 ` Torsten Bögershausen
  2025-01-06 15:05 ` Theodore Ts'o
  0 siblings, 2 replies; 7+ messages in thread
From: Chris Packham @ 2025-01-06  4:40 UTC (permalink / raw)
  To: GIT

Hi,

I look after some scripts we use at $dayjob for pushing changes though
our review system.

For some of our repositories we operate a triangular workflow where
changes are fetched from one branch (e.g. 'foo') but are pushed to a
different one ('foo_incoming'). Our CI system runs to test the changes
and when they pass 'foo_incoming' is merged (fast-forward most of the
time) into 'foo'.

The problem I have is not all our projects use this workflow so I've
tried to automate the detection of this. My script does something like

  br=$(git rev-parse --symbolic-full-name
refs/remotes/origin/foo_incoming -- 2>/dev/null || echo
refs/remotes/origin/foo)

The '--' is necessary because if foo_incoming doesn't exist then there
is extra output on stdout that puts off users. But when foo_incoming
does exist then br gets set to `refs/remotes/origin/foo_incoming\n--`.

Is there a better way of checking for the existence of a remote branch?

Thanks,
Chris

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-06 20:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06  4:40 Testing for existence of a remote branch from a script Chris Packham
2025-01-06  6:51 ` Torsten Bögershausen
2025-01-06 15:30   ` Junio C Hamano
2025-01-06 16:36     ` Theodore Ts'o
2025-01-06 18:44       ` Junio C Hamano
2025-01-06 20:50     ` Chris Packham
2025-01-06 15:05 ` Theodore Ts'o

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).