{"thread":{"id":"59912","subject":"Git question rewarding git merge and its exit codes","startedAt":"2023-06-26T12:16:41Z","lastAt":"2023-06-26T17:36:08Z","messageCount":3,"participants":["Iván Expósito","rsbecker@nexbridge.com"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"478790","messageId":"CAPDGPD5UK8+Z0ksX-tv2Rs8ESZ+LCY-Tic-dZSGV0QNStFN=Pg@mail.gmail.com","threadId":"59912","inReplyTo":null,"subject":"Git question rewarding git merge and its exit codes","fromName":"Iván Expósito","fromEmail":"byjokese@gmail.com","sentAt":"2023-06-26T12:14:33Z","receivedAt":"2023-06-26T12:16:41Z","isPatch":false,"sender":{"key":"byjokese@gmail.com","avatar":null},"body":"Hi, my name is Ivan.\n\nRecently, we have been working on some automations for Git, especially\nauto-merging some branches. Just noticed that when using: git merge\n--commit --no-ff -m \"test message\", and no changes are needed, git\nreturns  \"Already up-to-date\" with exit code 0. Is this correct? Git\nhasn't done anything, so not sure how correct is to return 0 for\nsuccess when nothing has been done. We have here a problem because the\nonly way we can detect if a commit has been made or not is to check\nthe return text, which is not the best idea for future-proof, or\nchanges in the return text.\n\nIs this exit code as defined, or maybe is something we would need to\nlook into for future improvements? Is there any other alternatives to\ndetect what has happened, not comparing the standard output text?\n\nThanks for your work, If any information is needed, don't hesitate to\ncontact me.\n\nThanks,\nIvan\n"},{"id":"478795","messageId":"004c01d9a842$77e75ee0$67b61ca0$@nexbridge.com","threadId":"59912","inReplyTo":"CAPDGPD5UK8+Z0ksX-tv2Rs8ESZ+LCY-Tic-dZSGV0QNStFN=Pg@mail.gmail.com","subject":"RE: Git question rewarding git merge and its exit codes","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2023-06-26T15:25:35Z","receivedAt":"2023-06-26T15:25:48Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Monday, June 26, 2023 8:15 AM, Iván Expósito wrote:\n>Recently, we have been working on some automations for Git, especially auto-\n>merging some branches. Just noticed that when using: git merge --commit --no-ff -m\n>\"test message\", and no changes are needed, git returns  \"Already up-to-date\" with\n>exit code 0. Is this correct? Git hasn't done anything, so not sure how correct is to\n>return 0 for success when nothing has been done. We have here a problem because\n>the only way we can detect if a commit has been made or not is to check the return\n>text, which is not the best idea for future-proof, or changes in the return text.\n>\n>Is this exit code as defined, or maybe is something we would need to look into for\n>future improvements? Is there any other alternatives to detect what has happened,\n>not comparing the standard output text?\n\nIf 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.\n\n--Randall\n\n--\nBrief whoami: NonStop&UNIX developer since approximately\nUNIX(421664400)\nNonStop(211288444200000000)\n-- In real life, I talk too much.\n\n\n\n"},{"id":"478832","messageId":"CAPDGPD4dftJenksUJePrHNjkXWJqQ+wTH9jaP_7BcgY8SMki7Q@mail.gmail.com","threadId":"59912","inReplyTo":"004c01d9a842$77e75ee0$67b61ca0$@nexbridge.com","subject":"Re: Git question rewarding git merge and its exit codes","fromName":"Iván Expósito","fromEmail":"byjokese@gmail.com","sentAt":"2023-06-26T17:35:06Z","receivedAt":"2023-06-26T17:36:08Z","isPatch":false,"sender":{"key":"byjokese@gmail.com","avatar":null},"body":"Thanks so much for the suggestions. I already thought on the first\none, comparing the SHA's, but not always same SHA's will ensure the\nmerge will have changes to be made (ideological would be the correct,\nbut some workflows won't ensure it). Will take a look using\n-no--commit and take a look with git status and the porcelain flag.\nThat may be easier and more secure.\n\nThanks for the answers.\n\nIvan\n\nEl lun, 26 jun 2023 a las 17:25, <rsbecker@nexbridge.com> escribió:\n>\n> On Monday, June 26, 2023 8:15 AM, Iván Expósito wrote:\n> >Recently, we have been working on some automations for Git, especially auto-\n> >merging some branches. Just noticed that when using: git merge --commit --no-ff -m\n> >\"test message\", and no changes are needed, git returns  \"Already up-to-date\" with\n> >exit code 0. Is this correct? Git hasn't done anything, so not sure how correct is to\n> >return 0 for success when nothing has been done. We have here a problem because\n> >the only way we can detect if a commit has been made or not is to check the return\n> >text, which is not the best idea for future-proof, or changes in the return text.\n> >\n> >Is this exit code as defined, or maybe is something we would need to look into for\n> >future improvements? Is there any other alternatives to detect what has happened,\n> >not comparing the standard output text?\n>\n> 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.\n>\n> --Randall\n>\n> --\n> Brief whoami: NonStop&UNIX developer since approximately\n> UNIX(421664400)\n> NonStop(211288444200000000)\n> -- In real life, I talk too much.\n>\n>\n>\n"}]}