git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <rsbecker@nexbridge.com>
To: "'Iván Expósito'" <byjokese@gmail.com>, git@vger.kernel.org
Subject: RE: Git question rewarding git merge and its exit codes
Date: Mon, 26 Jun 2023 11:25:35 -0400	[thread overview]
Message-ID: <004c01d9a842$77e75ee0$67b61ca0$@nexbridge.com> (raw)
In-Reply-To: <CAPDGPD5UK8+Z0ksX-tv2Rs8ESZ+LCY-Tic-dZSGV0QNStFN=Pg@mail.gmail.com>

On Monday, June 26, 2023 8:15 AM, Iván Expósito wrote:
>Recently, we have been working on some automations for Git, especially auto-
>merging some branches. Just noticed that when using: git merge --commit --no-ff -m
>"test message", and no changes are needed, git returns  "Already up-to-date" with
>exit code 0. Is this correct? Git hasn't done anything, so not sure how correct is to
>return 0 for success when nothing has been done. We have here a problem because
>the only way we can detect if a commit has been made or not is to check the return
>text, which is not the best idea for future-proof, or changes in the return text.
>
>Is this exit code as defined, or maybe is something we would need to look into for
>future improvements? Is there any other alternatives to detect what has happened,
>not comparing the standard output text?

If you want to script this, use --no-commit instead of --commit. After the merge runs, use git status --porcelain to determine whether merge performed any actions involving staging to unstaged (conflicts) files. This removes the need to use the completion code.

--Randall

--
Brief whoami: NonStop&UNIX developer since approximately
UNIX(421664400)
NonStop(211288444200000000)
-- In real life, I talk too much.




  reply	other threads:[~2023-06-26 15:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 12:14 Git question rewarding git merge and its exit codes Iván Expósito
2023-06-26 15:25 ` rsbecker [this message]
2023-06-26 17:35   ` Iván Expósito

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='004c01d9a842$77e75ee0$67b61ca0$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=byjokese@gmail.com \
    --cc=git@vger.kernel.org \
    /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).