diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-01-10 10:32:42 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-01-10 10:32:42 -0800 |
commit | 2da5cbd651114569b1a25d9b73c0e2afffb30aa7 (patch) | |
tree | 3aa0ed6450b24d67c0f62e756412dc2cd25e992d /diffcore-order.c | |
parent | f8c2e3f67133e82b1df9c4cc806ba5d67670e425 (diff) | |
parent | 6d8940b562adc5e43068868109dffe1b9bff7f78 (diff) | |
download | git-2da5cbd651114569b1a25d9b73c0e2afffb30aa7.tar.gz |
Merge branch 'sb/diff-orderfile-config'
Allow "git diff -O<file>" to be configured with a new configuration
variable.
* sb/diff-orderfile-config:
diff: add diff.orderfile configuration variable
diff: let "git diff -O" read orderfile from any file and fail properly
t4056: add new tests for "git diff -O"
Diffstat (limited to 'diffcore-order.c')
-rw-r--r-- | diffcore-order.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/diffcore-order.c b/diffcore-order.c index 50c089bb2b..fe7f1f4647 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -10,28 +10,21 @@ static int order_cnt; static void prepare_order(const char *orderfile) { - int fd, cnt, pass; + int cnt, pass; + struct strbuf sb = STRBUF_INIT; void *map; char *cp, *endp; - struct stat st; - size_t sz; + ssize_t sz; if (order) return; - fd = open(orderfile, O_RDONLY); - if (fd < 0) - return; - if (fstat(fd, &st)) { - close(fd); - return; - } - sz = xsize_t(st.st_size); - map = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - close(fd); - if (map == MAP_FAILED) - return; + sz = strbuf_read_file(&sb, orderfile, 0); + if (sz < 0) + die_errno(_("failed to read orderfile '%s'"), orderfile); + map = strbuf_detach(&sb, NULL); endp = (char *) map + sz; + for (pass = 0; pass < 2; pass++) { cnt = 0; cp = map; |