Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/helper/test-hexdump.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / helper / test-hexdump.c` 30 lines ยท 487 bytes Raw Blame History 1 #include "test-tool.h" 2 #include "git-compat-util.h" 3 4 /* 5 * Read stdin and print a hexdump to stdout. 6 */ 7 int cmd__hexdump(int argc UNUSED, const char **argv UNUSED) 8 { 9 char buf[1024]; 10 ssize_t i, len; 11 int have_data = 0; 12 13 for (;;) { 14 len = xread(0, buf, sizeof(buf)); 15 if (len < 0) 16 die_errno("failure reading stdin"); 17 if (!len) 18 break; 19 20 have_data = 1; 21 22 for (i = 0; i < len; i++) 23 printf("%02x ", (unsigned char)buf[i]); 24 } 25 26 if (have_data) 27 putchar('\n'); 28 29 return 0; 30 }