t/t7003-filter-branch.sh: use the $( ... ) construct for command substitution
[gitweb.git] / wt-status.c
index 82b87c1ea3ead748e6f40b90203a94294db5955f..bba25960b4e3c54a7c1d8861ea895fbe01aa3110 100644 (file)
@@ -1317,15 +1317,14 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
        target += strlen(" to ");
        strbuf_reset(&cb->buf);
        hashcpy(cb->nsha1, nsha1);
-       for (end = target; *end && *end != '\n'; end++)
-               ;
-       if (!memcmp(target, "HEAD", end - target)) {
+       end = strchrnul(target, '\n');
+       strbuf_add(&cb->buf, target, end - target);
+       if (!strcmp(cb->buf.buf, "HEAD")) {
                /* HEAD is relative. Resolve it to the right reflog entry. */
+               strbuf_reset(&cb->buf);
                strbuf_addstr(&cb->buf,
                              find_unique_abbrev(nsha1, DEFAULT_ABBREV));
-               return 1;
        }
-       strbuf_add(&cb->buf, target, end - target);
        return 1;
 }