First output line of `git -C dir ` (run with the test's clean env). */
| 133 | |
| 134 | /* First output line of `git -C dir <args>` (run with the test's clean env). */ |
| 135 | static void git_read_line(const char *dir, const char *args, char *out, size_t out_sz) { |
| 136 | char cmd[1024]; |
| 137 | out[0] = '\0'; |
| 138 | snprintf(cmd, sizeof(cmd), "git -C \"%s\" %s 2>/dev/null", dir, args); |
| 139 | FILE *fp = popen(cmd, "r"); |
| 140 | if (!fp) |
| 141 | return; |
| 142 | if (fgets(out, (int)out_sz, fp)) { |
| 143 | out[strcspn(out, "\r\n")] = '\0'; |
| 144 | } |
| 145 | pclose(fp); |
| 146 | } |
| 147 | |
| 148 | /* root/decoy: a repo on branch decoy-branch with coupled a.go+b.go commits; |
| 149 | * root/fixture: a repo on branch fixture-branch; root/plain: not a repo. */ |