Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

string_copy_rev: chop rev on first space (if any)

This allows tig to work with abbreviated commit hashes like:

    git log --format="commit %h %s" | tig
  • Loading branch information...
commit 44dd7132baa4d0bfc4341da3756dda5161ed7a48 1 parent bf17412
Vivien Didelot vivien authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 tig.h
13 tig.h
View
@@ -231,8 +231,17 @@ string_ncopy_do(char *dst, size_t dstlen, const char *src, size_t srclen)
#define string_ncopy(dst, src, srclen) \
string_ncopy_do(dst, sizeof(dst), src, srclen)
-#define string_copy_rev(dst, src) \
- string_ncopy_do(dst, SIZEOF_REV, src, SIZEOF_REV - 1)
+static inline void
+string_copy_rev(char *dst, const char *src)
+{
+ size_t srclen;
+
+ for (srclen = 0; srclen < SIZEOF_REV; srclen++)
+ if (isspace(src[srclen]))
+ break;
+
+ string_ncopy_do(dst, SIZEOF_REV, src, srclen);
+}
#define string_add(dst, from, src) \
string_ncopy_do(dst + (from), sizeof(dst) - (from), src, sizeof(src))
Please sign in to comment.
Something went wrong with that request. Please try again.